bio_polynow.F90 111 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757
!$id: bio_polynow.F90,v 1.11 2016-05-05 11:49:15 dd Exp $
#include"cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !MODULE: bio_fasham --- Fasham et al. biological model \label{sec:bio-fasham}
!
! !INTERFACE:
   module bio_polynow
!
!----DESCRIPTION:--------------------------------------------------------------
!  The model developed by Fashametal1990 
!  uses nitrogen as 'currency' according to the evidence that in
!  most cases nitrogen is the limiting macronutrient. It consists of
!  seven state variables: phytoplankton, zooplankton, bacteria,
!  particulate organic matter (detritus), dissolved organic matter
!  and the nutrients nitrate and ammonium.
!  The structure of the biogeochemical model in XXX states variables
! bacteria (bac),
! phytoplankton (phy), 
! detritus (det), 
! zooplankton (zoo), 
! labile dissolved
! organic nitrogen (don), 
! ammonium (amm) and nitrate (nit)
! XXX

! The concentrations are in mmol N\m^-3,and all fluxes are conservative.
!---------------------------------------------------------------------------------

! !USES:
!  default: all is private.
   use bio_var       ! S,T,zlev
   use output
   use observations, only : aa,g2
   use turbulence,   only : eps  
   use meanflow,     only : Rho_0 
   use eqstate,      only : eqstate1   ! In situ density in kg.m-3    

 
   private
!
! !PUBLIC MEMBER FUNCTIONS:
   public init_bio_polynow, init_var_polynow, var_info_polynow, &
          light_polynow, do_bio_polynow, end_bio_polynow
   REALTYPE, public,parameter   :: pi= 3.141592654
   REALTYPE, public,parameter   :: g= 9.80665 !m/s2 
   REALTYPE                     :: pres = 10.1325!  gauge pressure (absolute pressure - 10.1325 bar)
   REALTYPE,public    ::gauss_p



!-----LOCAL VARIABLES:---------- from a namelist : bio_polynow.nml----------------------

!INITIAL and Minimum concentration for the variable 

   REALTYPE                  ::  p_init_value=1.0
   REALTYPE                  ::  p_initial=0.01
   REALTYPE                  ::  z_p_gauss_init= 2.0
   REALTYPE                  ::  sigma_p=2.0

   REALTYPE                ::  zoo_init_value=1.0
   REALTYPE                  ::  z_initial=0.01
   REALTYPE                  ::  z_zoo_gauss_init= 2.0
   REALTYPE                  ::  sigma_zoo=2.0

   REALTYPE                  ::  b_initial= 0.001

!  Nitrate and ammonium are initialized within the GOTM observation module
!   REALTYPE                  ::  n_initial= 8.3
!   REALTYPE                  ::  a_initial= 0.22
!Classes de détritus et LDON

   REALTYPE                  ::  dph_init_value=1.0
   REALTYPE                  ::  dph_initial=0.01
   REALTYPE                  ::  z_dph_gauss_init= 2.0
   REALTYPE                  ::  sigma_dph=2.0

   REALTYPE                  ::  dzo_init_value=1.0
   REALTYPE                  ::  dzo_initial=0.01
   REALTYPE                  ::  z_dzo_gauss_init= 2.0
   REALTYPE                  ::  sigma_dzo=2.0

   REALTYPE                  ::  fp_init_value=1.0
   REALTYPE                  ::  fp_initial=0.01
   REALTYPE                  ::  z_fp_gauss_init= 2.0
   REALTYPE                  ::  sigma_fp=2.0

   REALTYPE                  ::  msn_init_value=1.0
   REALTYPE                  ::  msn_initial=0.01
   REALTYPE                  ::  z_msn_gauss_init= 2.0
   REALTYPE                  ::  sigma_msn=2.0

   REALTYPE                  ::  l_initial= 0.14
   REALTYPE                  ::  p0       = 0.0
   REALTYPE                  ::  z0       = 0.0
   REALTYPE                  ::  b0       = 0.0
   REALTYPE                  ::  mu5      = 0.02  !! GG-CHG1
!Phytoplankton
   REALTYPE                  ::  vp       = 1.5
   REALTYPE                  ::  alpha    = 0.065
   REALTYPE                  ::  inib     = 0.05
   REALTYPE, public          ::  kc       = 0.03
   REALTYPE                  ::  k1       = 0.2
   REALTYPE                  ::  k2       = 0.8
   REALTYPE                  ::  mu1      = 0.05
   REALTYPE                  ::  k5       = 0.2
   REALTYPE                  ::  gamma    = 0.05
   REALTYPE                  ::  txloss_p = 0.7  ! GG-D
   REALTYPE                  ::  txloss_dph = 0.05  ! GG-D

!Zooplankton
   REALTYPE                  ::  gmax     = 1.0
   REALTYPE                  ::  k3       = 1.0
   REALTYPE                  ::  beta     = 0.625
   REALTYPE                  ::  mu2      = 0.3
   REALTYPE                  ::  k6       = 0.2
   REALTYPE                  ::  delta    = 0.1
   REALTYPE                  ::  epsi     = 0.70
   REALTYPE                  ::  eg       = 0.05   ! GG-D
   REALTYPE                  ::  r1       = 0.55
   REALTYPE                  ::  r2       = 0.4
   REALTYPE                  ::  r3       = 0.05   !dph  GG-D
   REALTYPE                  ::  r4       = 0.05   !dzo  GG-D
   REALTYPE                  ::  r5       = 0.05   !fp   GG-D
   REALTYPE                  ::  r6       = 0.05   !msn  GG-D
   REALTYPE                  ::  zingest  = 0.05   ! GG-D
   REALTYPE                  ::  txloss_dzo = 0.05  ! GG-D
   REALTYPE                  ::  txloss_fp = 0.05  ! GG-D
! Vertical migration(From Ariadna Nocera)
  !LOGICAL  and integer doesn't work                  ::  Migra_zoo=.true.
   REALTYPE                   ::   Migra_zoo= 1.0   
   REALTYPE                  ::  pmin     = 0.05
   REALTYPE                  ::  w_zmax   = 100.0  !! GG-B
   REALTYPE                  ::  bertha   = 0.05   !! GG-B
   REALTYPE                  ::  parcrit  = 0.02   !! GG-B
!Bacterias
   REALTYPE                  ::  vb       = 1.2
   REALTYPE                  ::  remi = 0.1
   REALTYPE                  ::  k4       = 0.5
   REALTYPE                  ::  mu3      = 0.15
   REALTYPE                  ::  eta      = 0.0
   REALTYPE                  ::  mbac     = 0.0    ! GG-D
   REALTYPE                  ::dphlossb =0.4
   REALTYPE                  ::  dphlossl =  10.0  ! GG-D
   REALTYPE                  ::  dzolossl =  10.0  ! GG-D
   REALTYPE                  ::  dzolossb =  10.0  ! GG-D
   REALTYPE                  ::  fplossl  =   10.0 ! GG-D
   REALTYPE                  ::  fplossb  =   10.0 ! GG-D
   REALTYPE                  :: msnlossb =0.6
!LDON
   REALTYPE                  :: leak=0.1
   REALTYPE                  ::  mldon    = 0.02    ! GG-D
   REALTYPE                  ::  lmin     = 0.02    ! GG-D
!detritus/Settling
  ! LOGICAL                  ::  Phys_w= .true. 
  REALTYPE                   ::   size_w=0.0
  REALTYPE                   ::   Phys_w= 0.0 
  REALTYPE                   ::   w_msnow= 0.0 
   REALTYPE                  ::  w_p      = -0.5
   REALTYPE                  ::  w_dph    = -1.0    !!GG-C
   REALTYPE                  ::  w_dzo    = -10.0   !!GG-C
   REALTYPE                  ::  w_fp     = -100.0  !!GG-C
   REALTYPE                  ::  w_msn    = -2.0    !!GG-C

   REALTYPE                  ::  rho_p   = 0.02 
   REALTYPE                  ::  rho_dph      = 0.02 
   REALTYPE                  ::  rho_dzo      = 0.02 
   REALTYPE                  ::  rho_fp      = 0.02 
   REALTYPE                  ::  rho_msn      = 0.02 
!Aggregation
!   LOGICAL                   ::  Coag_coef=.true.   
   REALTYPE                    ::  Coag_coef=0.0      ! If true : utilisation of given parameters / False : utilisation of model calculate coefficient
! Coefficient de Kernel sans calcul via la physique  
   REALTYPE                  :: betap_p      = 0.2
   REALTYPE                  :: betap_dph=  1
   REALTYPE                  :: betap_dzo= 1
   REALTYPE                  :: betap_fp= 1 

   REALTYPE                  ::  betadph_dph = 0.2
   REALTYPE                  ::  betadph_dzo=   1
   REALTYPE                  ::  betadph_fp=   1
 
   REALTYPE                  ::  betadzo_dzo  = 0.02    
   REALTYPE                  ::  betadzo_fp  = 0.02  
   REALTYPE                  ::  betafp_fp   = 0.02    
!Calcul de la collision avec la physique
   REALTYPE                  ::  sti_cst = 0.0
   REALTYPE                  ::  stip_p     = -0.5  
   REALTYPE                  ::  stip_dph   = -0.5  
   REALTYPE                  ::  stip_dzo   = -0.5   
   REALTYPE                  ::  stip_fp    = -0.5   
   REALTYPE                  ::  stidph_dph     = -0.5  
   REALTYPE                  ::  stidph_dzo   = -0.5  
   REALTYPE                  ::  stidph_fp   = -0.5   
   REALTYPE                  ::  stidzo_dzo    = -0.5   
   REALTYPE                  ::  stidzo_fp   = -0.5   
   REALTYPE                  ::  stifp_fp   = -0.5   
!Collision rate and Settling
 REALTYPE                     :: min_flux_msn = 2.0E-09
 REALTYPE                     :: size_rand = 1.0
   REALTYPE                  ::  size_phy_us     = -0.5  
  REALTYPE                  ::  size_phy_up     = -0.5 
  REALTYPE                  ::   size_dph_us =  0.00001
  REALTYPE                  ::   size_dph_up =  0.00001
  REALTYPE                  ::   size_dzo_us=   0.000100
  REALTYPE                  ::   size_dzo_up=   0.000100
  REALTYPE                  ::   size_fp_us=    0.000050
  REALTYPE                  ::   size_fp_up=    0.000050 
   REALTYPE                  ::  size_msn     = -0.5  
!Parametres pour l'aggregation physique
   REALTYPE                  ::  dynvis      = -0.5  
   REALTYPE                  ::  kinvis      = -0.5  
   REALTYPE                  ::  kB          = -0.5  
!Fragmentation - Concentration seuil d'agrégat avant qu'un pourcentage parte dans le dph
  !logical                   ::  Frag_meth=.true.  !Utilisation de la physique ou pas pour la fragmentation
!  integer                   ::  Frag_meth=0.0
  REALTYPE                   ::  Frag_meth=0.0 
  REALTYPE                 ::  swim_brk = 0.8
REALTYPE                 ::Floc_coef = 0.1
REALTYPE                 ::lim_size=3.0
!Tests parameter 
  REALTYPE                 ::betaBr=1.0
  REALTYPE                 ::betaSh =1.0 
  REALTYPE                 ::betaDs =1.0 
  REALTYPE                 ::eps_const =1.0 
  REALTYPE                 ::eps_n =1.0 
  REALTYPE                 ::cons_min= 0.00001

 REALTYPE                  ::write_screen

   integer                   ::  out_unit
   integer, parameter        ::  p=1,z=2,b=3,d1=4,n=5,a=6,l=7,d2=8,d3=9,d4=10,aug_si_d4=11,taille_msn=12 
! GG  d1= dph , d2= dzo , d3= fp , d4 = msn, aug_si_d4= size_msn

!EOP
!-----------------------------------------------------------------------

   contains

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Initialise the bio module
!
! !INTERFACE:
   subroutine init_bio_polynow(namlst,fname,unit)
!
! !DESCRIPTION:
!  Here, the bio namelist bio_polynow.nml is read and
!  various variables (rates and settling velocities)
!  are transformed into SI units.
!
! !USES:
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
   integer,          intent(in)   :: namlst
   character(len=*), intent(in)   :: fname
   character(len=20)              :: pfile
   integer,          intent(in)   :: unit
!
! !REVISION HISTORY:
!  Original author(s): Hans Burchard & Karsten Bolding
!
! !LOCAL VARIABLES:
   namelist /bio_polynow_nml/ numc, &
                                                        
                        p_init_value,p_initial,z_p_gauss_init,sigma_p,   &
zoo_init_value,z_initial,z_zoo_gauss_init,sigma_zoo, &
b_initial,                       &
dph_init_value,dph_initial,z_dph_gauss_init,sigma_dph,  &
dzo_init_value,dzo_initial,z_dzo_gauss_init,sigma_dzo,  &
fp_init_value,fp_initial,z_fp_gauss_init,sigma_fp, &
                        msn_init_value,msn_initial,z_msn_gauss_init,sigma_msn,                                     & 
                        l_initial,p0,z0,b0,mu5,                                                                  &
                        vp,alpha,inib,kc,k1,k2,mu1,k5,gamma,txloss_p,txloss_dph,             & ! phytoplankton 
                        gmax,k3,beta,mu2,k6,delta,epsi,eg,r1,r2,r3,r4,r5,r6,zingest,                             & ! zooplankton   
                        txloss_dzo,txloss_fp, &
                        Migra_zoo,pmin,w_zmax,bertha,parcrit,                                                    & !Vertical migration from Nocera 
                        vb,remi,k4,mu3,eta,mbac,dphlossb,dphlossl,dzolossl,dzolossb,fplossl,fplossb,msnlossb, & !Bacterias 
                        leak,mldon,lmin,                                                                              & !LDON      
                         size_w,Phys_w,w_msnow,w_p,w_dph,w_dzo,w_fp,w_msn,                                                       & !Detritus
rho_p,rho_dph,rho_dzo,rho_fp,rho_msn,                                                    &    
                        Coag_coef,     &
                        betap_p,betap_dph,betap_dzo,betap_fp, &
                        betadph_dph,betadph_dzo,betadph_fp, &
                        betadzo_dzo,betadzo_fp,betafp_fp  ,                                                & !Aggregation
                        sti_cst, &
                        stip_p,stip_dph,stip_dzo,stip_fp,stidph_dph,stidph_dzo,stidph_fp,stidzo_dzo,stidzo_fp,stifp_fp, &
                     min_flux_msn,size_rand,size_phy_us,size_phy_up,size_dph_us,size_dph_up,size_dzo_us,size_dzo_up,&
  size_fp_us,size_fp_up,size_msn,&
                        dynvis,kinvis,kB,                                                                         &
                        Frag_meth,swim_brk,                                                           &
Floc_coef,lim_size,                &
                        betaBr,betaSh,betaDs,                                                                     &
                        eps_const,eps_n,cons_min, &
                        write_screen                                             

!EOP
!-----------------------------------------------------------------------
!BOC
   LEVEL2 'init_bio_polynow'

   open(namlst,file=fname,action='read',status='old',err=98)
   read(namlst,nml=bio_polynow_nml,err=99)
   close(namlst)

   numcc=numc
!----Print some parameter values in standard output and save them in a separate file [out_fn]_polynow.par
   pfile = trim(out_fn) // '_polynow.par'
   open(10,status='unknown',action='write',file=pfile)
   LEVEL3 'Biogeochemical parameters saved in ', pfile


  !p_init_value=1.0
   write(*,900) '                p_initial     = ',p_initial
   write(10,901) p_initial
  !z_p_gauss_init= -10
  !sigma_p= 2.0
!zoo_init_value      
   write(*,900) '                z_initial     = ',z_initial
   write(10,901) z_initial  
! z_zoo_gauss_init   
!  sigma_zoo         
   write(*,900) '                b_initial     = ',b_initial
   write(10,901) b_initial
!dph_init_value=1.0
   write(*,900) '                dph_initial     = ',dph_initial
   write(10,901) dph_initial
  !z_dph_gauss_init= -10
  !sigma_dph= 2.0
!dzo_init_value=1.0
   write(*,900) '                dzo_initial     = ',dzo_initial
   write(10,901) dzo_initial
 !z_dzo_gauss_init= -10
  !sigma_dzo= 2.0
!fp_init_value=1.0
   write(*,900) '                fp_initial     = ',fp_initial
   write(10,901) fp_initial
 !z_fp_gauss_init= -10
  !sigma_fp= 2.0
!msn_init_value=1.0
   write(*,900) '                msn_initial     = ',msn_initial
   write(10,901) msn_initial
 !z_msn_gauss_init= -10
  !sigma_msn= 2.0
   write(*,900) '                l_initial     = ',l_initial
   write(10,901) l_initial
   write(*,900) '                p0     = ',p0
   write(10,901) p0
   write(*,900) '                z0     = ',z0
   write(10,901) z0
   write(*,900) '                b0     = ',b0
   write(10,901) b0
   write(*,900) '                mu5     = ',mu5
   write(10,901) mu5
   write(*,900) '                vp     = ',vp
   write(10,901) vp
   write(*,900) '                alpha  = ',alpha
   write(10,901) alpha
   write(*,900) '                inib   = ',inib
   write(10,901) inib
   write(*,900) '                kc     = ',kc
   write(10,901) kc
   write(*,900) '                k1     = ',k1
   write(10,901) k1
   write(*,900) '                k2     = ',k2
   write(10,901) k2
   write(*,900) '                mu1     = ',mu1
   write(10,901) mu1
   write(*,900) '                k5     = ',k5
   write(10,901) k5
   write(*,900) '               gamma     = ',gamma
   write(10,901) gamma
   write(*,900) '               txloss_p = ',txloss_p
   write(10,901) txloss_p
   write(*,900) '               txloss_dph = ',txloss_dph
   write(10,901) txloss_dph
   write(*,900) '                gmax  = ',gmax
   write(10,901) gmax
   write(*,900) '                k3     = ',k3
   write(10,901) k3
   write(*,900) '                beta     = ',beta
   write(10,901) beta
   write(*,900) '                mu2      = ',mu2
   write(10,901) mu2
   write(*,900) '                k6     = ',k6
   write(10,901) k6
   write(*,900) '                delta    = ',delta
   write(10,901) delta
   write(*,900) '                epsi    = ',epsi
   write(10,901) epsi
   write(*,900) '                eg     = ',eg
   write(10,901) eg
   write(*,900) '                r1     = ',r1
   write(10,901) r1
   write(*,900) '                r2   = ',r2
   write(10,901) r2
   write(*,900) '                r3    = ',r3
   write(10,901) r3
   write(*,900) '                r4    = ',r4
   write(10,901) r4
   write(*,900) '                r5     = ',r5
   write(10,901) r5
   write(*,900) '                r6     = ',r6
   write(10,901) r6
   write(*,900) '                zingest     = ',zingest
   write(10,901) zingest
   write(*,900) '               txloss_dzo = ',txloss_dzo
   write(10,901) txloss_dzo
   write(*,900) '               txloss_fp = ',txloss_fp
   write(10,901) txloss_fp
   write(*,900) '               Migra_zoo = ',Migra_zoo
   write(10,901) Migra_zoo
   write(*,900) '                pmin     = ',pmin
   write(10,901) pmin
   write(*,900) '                w_zmax    = ',w_zmax
   write(10,901) w_zmax
   write(*,900) '                bertha    = ',bertha
   write(10,901) bertha
   write(*,900) '                parcrit     = ',parcrit
   write(10,901) parcrit
   write(*,900) '                vb    = ',vb
   write(10,901) vb
!remi
   write(*,900) '                k4    = ',k4
   write(10,901) k4
   write(*,900) '                mu3    = ',mu3
   write(10,901) mu3
   write(*,900) '                eta    = ',eta
   write(10,901) eta
   write(*,900) '                mbac    = ',mbac
   write(10,901) mbac
   write(*,900) '                dphlossb    = ',dphlossb
   write(10,901) dphlossb
   write(*,900) '               dphlossl    = ',dphlossl
   write(10,901) dphlossl
   write(*,900) '               dzolossl    = ',dzolossl
   write(10,901) dzolossl
   write(*,900) '               dzolossb   = ',dzolossb
   write(10,901) dzolossb
   write(*,900) '               fplossl    = ',fplossl
   write(10,901) fplossl
   write(*,900) '               fplossb   = ',fplossb
   write(10,901) fplossb
   write(*,900) '               msnlossb   = ',msnlossb
   write(10,901) msnlossb
!leak
   write(*,900) '               mldon   = ',mldon
   write(10,901) mldon
   write(*,900) '               lmin   = ',lmin
   write(10,901) lmin
! size_w
   write(*,900) '               Phys_w   = ',Phys_w
   write(10,901) Phys_w
!w_msnow
   write(*,900) '               w_p   = ',w_p
   write(10,901) w_p
   write(*,900) '               w_dph    = ',w_dph
   write(10,901) w_dph
   write(*,900) '               w_dzo    = ',w_dzo
   write(10,901) w_dzo
   write(*,900) '               w_fp  = ',w_fp
   write(10,901) w_fp
   write(*,900) '               w_msn    = ',w_msn
   write(10,901) w_msn

  ! write(*,900) '               rho_p    = ',rho_p
 !  write(10,901) rho_p
!   write(*,900) '               rho_dph    = ',rho_dph
!   write(10,901) rho_dph
   write(*,900) '               rho_dzo    = ',rho_dzo
   write(10,901) rho_dzo
   write(*,900) '               rho_fp    = ',rho_fp
   write(10,901) rho_fp
   write(*,900) '               rho_msn    = ',rho_msn
   write(10,901) rho_msn
   write(*,900) '               coag_coef    = ',coag_coef
   write(10,901) coag_coef
   write(*,900) '               betap_p   = ',betap_p
   write(10,901) betap_p

!betap_dph,betap_dzo,betap_fp

   write(*,900) '               betadph_dph   = ',betadph_dph
   write(10,901) betadph_dph

! betadph_dzo,betadph_fp,

   write(*,900) '               betadzo_dzo   = ',betadzo_dzo
   write(10,901) betadzo_dzo
!betadzo_fp
   write(*,900) '               betafp_fp   = ',betafp_fp
   write(10,901) betafp_fp
!sti_cst
   write(*,900) '               stip_p   = ',stip_p
   write(10,901) stip_p
   write(*,900) '               stip_dph   = ',stip_dph
   write(10,901) stip_dph
   write(*,900) '               stip_dzo   = ',stip_dzo
   write(10,901) stip_dzo
   write(*,900) '               stip_fp   = ',stip_fp
   write(10,901) stip_fp
   write(*,900) '               stidph_dph   = ',stidph_dph
   write(10,901) stidph_dph
   write(*,900) '               stidph_dzo   = ',stidph_dzo
   write(10,901) stidph_dzo
   write(*,900) '               stidph_fp   = ',stidph_fp
   write(10,901) stidph_fp
   write(*,900) '               stidzo_dzo   = ',stidzo_dzo
   write(10,901) stidzo_dzo
   write(*,900) '               stidzo_fp   = ',stidzo_fp
   write(10,901) stidzo_fp
   write(*,900) '               stifp_fp   = ',stifp_fp
   write(10,901) stifp_fp
!min_flux_msn
   write(*,900) '               size_phy_us   = ',size_phy_us
   write(10,901) size_phy_us
!size_phy_up
   write(*,900) '               size_dph_us   = ',size_dph_us
   write(10,901) size_dph_us
   write(*,900) '               size_dzo_us   = ',size_dzo_us
   write(10,901) size_dzo_us
   write(*,900) '               size_fp_us  = ',size_fp_us
   write(10,901) size_fp_us

 !size_dph_up =  0.00001
 !size_dzo_up=   0.000100
 !size_fp_up=    0.000050
   write(*,900) '               size_msn   = ',size_msn
   write(10,901) size_msn
   write(*,900) '               dynvis   = ',dynvis
   write(10,901) dynvis
   write(*,900) '               kinvis   = ',kinvis
   write(10,901) kinvis
   write(*,900) '               kB   = ',kB
   write(10,901) kB
   write(*,900) '               Frag_meth   = ',Frag_meth
   write(10,901) Frag_meth
   write(*,900) '                swim_brk   = ', swim_brk
   write(10,901)  swim_brk
!betaBr
!betaSh
!betaDs
!eps_const
!eps
!cons_min
!Floc_coef 
!lim_size

900 format (a,f8.5)
901 format (f8.5)

!  Conversion from day to second
   mu5      = mu5 /secs_pr_day       
   vp       = vp /secs_pr_day
   alpha    = alpha /secs_pr_day                
   inib     = inib /secs_pr_day         
   mu1      = mu1 /secs_pr_day

   gmax     = gmax /secs_pr_day
   mu2      = mu2 /secs_pr_day
   w_zmax   = w_zmax /secs_pr_day       

   vb       = vb /secs_pr_day
  remi = remi/secs_pr_day
   mu3      = mu3 /secs_pr_day
   mbac     = mbac /secs_pr_day       
 dphlossb    =dphlossb/secs_pr_day 
  dphlossl  = dphlossl/secs_pr_day 
  dzolossl  = dzolossl/secs_pr_day 
  dzolossb  = dzolossb/secs_pr_day 
  fplossl  = fplossl/secs_pr_day
  fplossb  = fplossb/secs_pr_day
  msnlossb= msnlossb/secs_pr_day
leak=leak/secs_pr_day 
  mldon    = mldon /secs_pr_day       

   w_p      = w_p /secs_pr_day
   w_dph    = w_dph /secs_pr_day    
   w_dzo    = w_dzo /secs_pr_day    
   w_fp     = w_fp /secs_pr_day    
   w_msn    = w_msn /secs_pr_day    


!Phytoplankton
txloss_p = txloss_p /secs_pr_day   
betap_p    = betap_p /secs_pr_day    ! GG-D
betap_dph    = betap_dph /secs_pr_day    ! GG-D
betap_dzo    = betap_dzo /secs_pr_day    ! GG-D
betap_fp    = betap_fp /secs_pr_day    ! GG-D

!Dead-Phytoplankton
txloss_dph= txloss_dph /secs_pr_day 
betadph_dph =betadph_dph/secs_pr_day 
betadph_dzo=betadph_dzo/secs_pr_day 
betadph_fp=betadph_fp/secs_pr_day 

!Dead-Zooplankton
txloss_dzo= txloss_dzo /secs_pr_day 
betadzo_dzo  = betadzo_dzo /secs_pr_day    
betadzo_fp  = betadzo_fp /secs_pr_day    

!Fecal pellets
txloss_fp= txloss_fp /secs_pr_day 
betafp_fp   = betafp_fp /secs_pr_day    

 dynvis = dynvis/secs_pr_day
 kinvis = dynvis/secs_pr_day

 swim_brk   =  swim_brk /secs_pr_day
 !eps cm2. sec-3

   out_unit=unit

   LEVEL3 'polynow bio module initialised ...'

   return

98 LEVEL2 'I could not open bio_polynow.nml'
   LEVEL2 'If thats not what you want you have to supply bio_polynow.nml'
   LEVEL2 'See the bio example on www.gotm.net for a working bio_polynow.nml'
   return
99 FATAL 'I could not read bio_polynow.nml'
   stop 'init_bio_polynow'
   end subroutine init_bio_polynow
!EOC

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Initialise the concentration variables
!
! !INTERFACE:
   subroutine init_var_polynow(nlev)
!
! !DESCRIPTION:
!  Here, the the initial conditions are set and the settling velocities are
!  transferred to all vertical levels. All concentrations are declared
!  as non-negative variables, and it is defined which variables would be
!  taken up by benthic filter feeders.
!
! !USES:
   use observations,    only: nprof,aprof              !CHG3-5
   use meanflow,        only: nit,amm,T,S               !CHG3-5


   IMPLICIT NONE

!
! !INPUT PARAMETERS:
   integer, intent(in)                 :: nlev

!
! !REVISION HISTORY:
!  Original author(s): Hans Burchard & Karsten Bolding

! !LOCAL VARIABLES:
  integer                    :: i,j
  REALTYPE    ::gauss_p,gauss_dph,gauss_dzo,gauss_fp,gauss_msn,gauss_zoo

!EOP
!-----------------------------------------------------------------------
!BOC

!-----------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------
!   Variable INITIAL PROFILES
!-----------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------

   do i=1,nlev

!-----------------------------------------------------------------------------------
!   Phytoplankton initial profile
!-----------------------------------------------------------------------------------

!!       ---If p_init_value .eq.1 --» Cst initial value for all the depth as mentionned in the nml.
if (p_init_value .eq. 1.0) then
      cc(p,i)=p_initial
!!       ---If p_init_value .eq.0 --» Initial profile describe according to gaussian curve (Mean + standard error)
else
  gauss_p=p_initial*exp(-((i-z_p_gauss_init)**2/(2*(sigma_p**2))))
     cc(p,i)= gauss_p
endif

!-----------------------------------------------------------------------------------
!   Zooplankton initial profiles
!-----------------------------------------------------------------------------------

!       ---If zoo_init_value .eq.1 --» Cst initial value for all the depth as mentionned in the nml.
if (zoo_init_value .eq. 1.0) then
      cc(z,i)=z_initial
!       ---If zoo_init_value.eq.0 --» Initial profile describe according to gaussian curve (Mean + standard error)
else
  gauss_zoo=z_initial*exp(-((i-z_zoo_gauss_init)**2/(2*(sigma_zoo**2))))
     cc(z,i)= gauss_zoo
endif
!-----------------------------------------------------------------------------------
!   Dead- Phytoplankton initial profile
!-----------------------------------------------------------------------------------

!!       ---If dph_init_value .eq.1 --» Cst initial value for all the depth as mentionned in the nml.
if (dph_init_value .eq. 1.0) then
      cc(d1,i)=dph_initial
!!       ---If dph_init_value .eq.0 --» Initial profile describe according to gaussian curve (Mean + standard error)
else
  gauss_dph=dph_initial*exp(-((i-z_dph_gauss_init)**2/(2*(sigma_dph**2))))
     cc(d1,i)= gauss_dph
endif

!-----------------------------------------------------------------------------------
!   Dead- Zooplankton initial profile
!-----------------------------------------------------------------------------------

!!       ---If dzo_init_value .eq.1 --» Cst initial value for all the depth as mentionned in the nml.
if (dzo_init_value .eq. 1.0) then
      cc(d2,i)=dzo_initial
!!       ---If dzo_init_value .eq.0 --» Initial profile describe according to gaussian curve (Mean + standard error)
else
  gauss_dzo=dzo_initial*exp(-((i-z_dzo_gauss_init)**2/(2*(sigma_dzo**2))))
     cc(d2,i)= gauss_dzo
endif

!-----------------------------------------------------------------------------------
!   Fecal pellets initial profile
!-----------------------------------------------------------------------------------

!!       ---If fp_init_value .eq.1 --» Cst initial value for all the depth as mentionned in the nml.
if (fp_init_value .eq. 1.0) then
      cc(d3,i)=fp_initial
!!       ---If fp_init_value .eq.0 --» Initial profile describe according to gaussian curve (Mean + standard error)
else
  gauss_fp=fp_initial*exp(-((i-z_fp_gauss_init)**2/(2*(sigma_fp**2))))
     cc(d3,i)= gauss_fp
endif

!-----------------------------------------------------------------------------------
!   Marine snow initial profile
!-----------------------------------------------------------------------------------

!!       ---If msn_init_value .eq.1 --» Cst initial value for all the depth as mentionned in the nml.
if (msn_init_value .eq. 1.0) then
      cc(d4,i)=msn_initial
!!       ---If msn_init_value.eq.0 --» Initial profile describe according to gaussian curve (Mean + standard error)
else
  gauss_msn=msn_initial*exp(-((i-z_msn_gauss_init)**2/(2*(sigma_msn**2))))
     cc(d4,i)= gauss_msn
endif


!-----------------------------------------------------------------------------------
!  Bacteria- Nitrate/ammonium / LDON initial profiles
!-----------------------------------------------------------------------------------
      cc(b,i)=b_initial
      cc(n,i)=nprof(i)       
      cc(a,i)=aprof(i)       
      cc(l,i)=l_initial

   end do

!-----------------------------------------------------------------------------------
!   Settling/swimming velocity
!-----------------------------------------------------------------------------------

   do i=0,nlev
      ws(z,i) = _ZERO_
      ws(b,i) = _ZERO_
      ws(n,i) = _ZERO_
      ws(a,i) = _ZERO_
      ws(l,i) = _ZERO_

if(Phys_w .eq. 0.0) then   
      ws(p,i) = w_p
      ws(d1,i)= w_dph   
      ws(d2,i)= w_dzo   
      ws(d3,i)= w_fp    
      ws(d4,i)= w_msn 
else
     ws(p,i) =_ZERO_           
     ws(d1,i)=_ZERO_
     ws(d2,i)=_ZERO_ 
     ws(d3,i)=_ZERO_ 
     ws(d4,i)=_ZERO_ 

end if

!-----------------------------------------------------------------------------------
!   Marine Snow Size and settling velocity
!-----------------------------------------------------------------------------------
  cc(aug_si_d4,i) =_ZERO_
  cc(taille_msn,i)=_ZERO_
  ws(taille_msn,i)=_ZERO_

   end do

   posconc(p) = 1
   posconc(z) = 1
   posconc(b) = 1
   posconc(n) = 1
   posconc(a) = 1
   posconc(l) = 1
  
  posconc(d1) = 1 !GG-C
  posconc(d2) = 1 !GG-C
  posconc(d3) = 1 !GG-C
  posconc(d4) = 1 !GG-C

#if 0
   mussels_inhale(p) = .true.
   mussels_inhale(z) = .true.
   mussels_inhale(b) = .false.
   mussels_inhale(n) = .false.
   mussels_inhale(a) = .false.
   mussels_inhale(l) = .true.
 
   mussels_inhale(d1) = .true.  
   mussels_inhale(d2) = .true.  
   mussels_inhale(d3) = .true.  
   mussels_inhale(d4) = .true.  

#endif

   LEVEL3 'polynow variables initialised ...'

   return

   end subroutine init_var_polynow
!EOC

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Providing info on variables
!
! !INTERFACE:
   subroutine var_info_polynow()
!
! !DESCRIPTION:
!  This subroutine provides information about the variable names as they
!  will be used when storing data in NetCDF files.
!
! !USES:
   IMPLICIT NONE
!
! !REVISION HISTORY:
!  Original author(s): Hans Burchard & Karsten Bolding
!
! !LOCAL VARIABLES:
!EOP
!-----------------------------------------------------------------------
!BOC
   var_names(1) = 'phy'
   var_units(1) = 'mmol/m**3'
   var_long(1)  = 'phytoplankton'

   var_names(2) = 'zoo'
   var_units(2) = 'mmol/m**3'
   var_long(2)  = 'zooplankton'

   var_names(3) = 'bac'
   var_units(3) = 'mmol/m**3'
   var_long(3)  = 'bacteria'

   var_names(4) = 'dph'                
   var_units(4) = 'mmol/m**3'
   var_long(4)  = 'dead phytoplankton'

   var_names(5) = 'nit'
   var_units(5) = 'mmol/m**3'
   var_long(5)  = 'nitrate'

   var_names(6) = 'amm'
   var_units(6) = 'mmol/m**3'
   var_long(6)  = 'ammonium'

   var_names(7) = 'ldn'
   var_units(7) = 'mmol/m**3'
   var_long(7)  = 'labile_dissolved_organic_nitrogen'

   var_names(8) = 'dzo'                            
   var_units(8) = 'mmol/m**3'                      
   var_long(8)  = 'dead zooplankton'           

   var_names(9) = 'fp'                              
   var_units(9) = 'mmol/m**3'
   var_long(9)  = 'fecal pellets'

   var_names(10) = 'msn'                          
   var_units(10) = 'mmol/m**3'
   var_long(10)  = 'marine snow'

!--------------------------------------------------

   var_names(11) = 'aug_si_d4'                          
   var_units(11) = 'm'
   var_long(11)  = 'augmentation size of marine snow'

   var_names(12) = 'taille_msn'                          
   var_units(12) = 'm'
   var_long(12)  = 'Taille de la neige marine'

   return
   end subroutine var_info_polynow
!EOC

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Light properties for the Fasham model
!
! !INTERFACE:
   subroutine light_polynow(nlev,bioshade_feedback)
!
! !DESCRIPTION:
! Here, the photosynthetically available radiation is calculated
! by simply assuming that the short wave part of the total
! radiation is available for photosynthesis. 
! The photosynthetically
! available radiation, $I_{PAR}$, follows from (\ref{light}).
! The user should make
! sure that this is consistent with the light class given in the
! {\tt extinct} namelist of the {\tt obs.nml} file.
! The self-shading effect is also calculated in this subroutine,
! which may be used to consider the effect of bio-turbidity also
! in the temperature equation (if {\tt bioshade\_feedback} is set
! to true in {\tt bio.nml}).
! For details, see section \ref{sec:do-bio}.
!
! !USES:
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
  integer, intent(in)                  :: nlev
  logical, intent(in)                  :: bioshade_feedback
!
! !REVISION HISTORY:
!  Original author(s): Hans Burchard, Karsten Bolding
!
! !LOCAL VARIABLES:
   integer                   :: i
   REALTYPE                  :: zz,add
!EOP
!-----------------------------------------------------------------------
!BOC
   zz = _ZERO_
   add = _ZERO_
   do i=nlev,1,-1
      add=add+0.5*h(i)*(cc(p,i)+p0)
      zz=zz+0.5*h(i)
      par(i)=rad(nlev)*(1.-aa)*exp(-zz/g2)*exp(-kc*add)
      add=add+0.5*h(i)*(cc(p,i)+p0)
      zz=zz+0.5*h(i)
      if (bioshade_feedback) bioshade_(i)=exp(-kc*add)
   end do


   return
   end subroutine light_polynow
!EOC

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Right hand sides of geobiochemical model \label{sec:bio-fasham-rhs}
!
! !INTERFACE:
   subroutine do_bio_polynow(first,numc,nlev,cc,pp,dd)
!
! !DESCRIPTION:
! The model consisting of the following state variable:
! phytoplankton, bacteria, detritus (4 types), zooplankton, 
! nitrate, ammonium and dissolved organic nitrogen.
!
! !BIBLIOGRAPHY:
! Platt et al., 1980- Moore et al., 2002-Alldredge and Gotschalk 1988 -Kajihara 1971
!Komar 1981-Ghosh 2013 - Mc Donnell 2010 - Alldredge 1990

! Biddanda 1998
! Ploug and Grossart 2000
! Jokulsdottir 2011
! Jackson 1990
!
! !USES:
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
   logical, intent(in)                 :: first
   integer, intent(in)                 :: numc,nlev
   REALTYPE   ::gauss_p
 
   REALTYPE, intent(out)                :: cc(1:numc,0:nlev)
!With INTENT(IN), you are promising to the compiler that argument cc is not modified nor its definition status changed. 


! !OUTPUT PARAMETERS:
   REALTYPE, intent(out)               :: pp(1:numc,1:numc,0:nlev)
   REALTYPE, intent(out)               :: dd(1:numc,1:numc,0:nlev)

!Similarly, INTENT(OUT) says that variables pp and dd are always assigned a value in the routine.

!
! !LOCAL VARIABLES:
   integer                    :: i,j,ci
!   Light and nutrient limitation factors & Zooplankton and bacterias needed factors
   REALTYPE                   :: Ps,ff
   REALTYPE                   :: q1,q2
   REALTYPE                   :: fac,min67
!!   Size variation for each particle type
   REALTYPE                   ::size_phy,size_dph,size_dzo,size_fp
!Collision & Aggregation
!!   Sedimentation rate for each particle type
     REALTYPE                    ::w_p_m,w_dph_m,w_dzo_m,w_fp_m
     REALTYPE                    ::rho_F
     REALTYPE                    ::Rp,Rdph,Rdzo,Rfp
!!   Maximum loss for aggregation for each particle type
      REALTYPE                    ::pprime   
      REALTYPE                    ::d1rime  
      REALTYPE                    ::d2rime
      REALTYPE                    ::d3rime
!!   Stickiness for each particle type interaction
      REAL                        :: r_phy, r_dph, r_dzo, r_fp
      REALTYPE                     ::stip ,stidph,stidzo,stifp
!'No physical coagulation happens here [Constant Beta are set]'
! Phytoplankton loss by aggregation
      REALTYPE                    ::coli_pp_NoPhys,agg_pp
      REALTYPE                    ::coli_pdph_NoPhys,agg_pdph
      REALTYPE                    ::coli_pdzo_NoPhys,agg_pdzo
      REALTYPE                    ::coli_pfp_NoPhys,agg_pfp
! Dead Phytoplankton loss by aggregation
      REALTYPE                    ::coli_dphdph_NoPhys,agg_dphdph
      REALTYPE                    ::coli_dphdzo_NoPhys,agg_dphdzo
      REALTYPE                    :: coli_dphfp_NoPhys,agg_dphfp
! Dead Zooplankton loss by aggregation
      REALTYPE                    ::coli_dzodzo_NoPhys,agg_dzodzo
      REALTYPE                    ::coli_dzofp_NoPhys,agg_dzofp
! Fecal pellets loss by aggregation
      REALTYPE                    ::coli_fpfp_NoPhys,agg_fpfp
!Coagulate only with : BetaBR'
      REALTYPE                    ::T_degK
      REALTYPE                    ::physic_Br
  !Phytoplankton
      REALTYPE                    :: betaBr_pp,coli_pp
      REALTYPE                    :: betaBr_pdph,coli_pdph
      REALTYPE                    :: betaBr_pdzo,coli_pdzo
      REALTYPE                    :: betaBr_pfp,coli_pfp
  !Dead Phytoplankton
      REALTYPE                    :: betaBr_dphdph,coli_dphdph
      REALTYPE                    :: betaBr_dphdzo,coli_dphdzo
      REALTYPE                    :: betaBr_dphfp,coli_dphfp
  !Dead Zooplankton
      REALTYPE                    :: betaBr_dzodzo,coli_dzodzo
      REALTYPE                    :: betaBr_dzofp,coli_dzofp
  !Fecal pellets
      REALTYPE                    :: betaBr_fpfp,coli_fpfp
!Coagulate only with : BetaSh'
      REALTYPE                    ::bio_eps
  !Phytoplankton
      REALTYPE                    ::q_pp,betaSh_pp
      REALTYPE                    ::q_pdph,betaSh_pdph
      REALTYPE                    ::q_pdzo,betaSh_pdzo
      REALTYPE                    ::q_pfp,betaSh_pfp
  !Dead Phytoplankton
      REALTYPE                    ::q_dphdph,betaSh_dphdph
      REALTYPE                    ::q_dphdzo,betaSh_dphdzo
      REALTYPE                    ::q_dphfp,betaSh_dphfp
  !Dead Zooplankton
      REALTYPE                    ::q_dzodzo,betaSh_dzodzo
      REALTYPE                    ::q_dzofp,betaSh_dzofp
  !Fecal pellets
      REALTYPE                    ::q_fpfp,betaSh_fpfp
!Coagulate only with : BetaDs'
  !Phytoplankton
      REALTYPE                    ::abs_pp, betaDs_pp
      REALTYPE                    ::abs_pdph,betaDs_pdph
      REALTYPE                    ::abs_pdzo,betaDs_pdzo
      REALTYPE                    ::abs_pfp,betaDs_pfp
  !Dead Phytoplankton
      REALTYPE                    :: abs_dphdph,betaDs_dphdph
      REALTYPE                    :: abs_dphdzo,betaDs_dphdzo
      REALTYPE                    :: abs_dphfp,betaDs_dphfp
  !Dead Zooplankton
      REALTYPE                    :: abs_dzodzo,betaDs_dzodzo
      REALTYPE                    :: abs_dzofp,betaDs_dzofp
  !Fecal pellets
      REALTYPE                    :: abs_fpfp,betaDs_fpfp
!'Physical Coagulation happens here ![Beta are calculated via physic]'
  !Phytoplankton
      REALTYPE                    ::kernel_coef_pp
      REALTYPE                    ::kernel_coef_pdph
      REALTYPE                    ::kernel_coef_pdzo
      REALTYPE                    ::kernel_coef_pfp
  !Dead Phytoplankton
      REALTYPE                    :: kernel_coef_dphdph
      REALTYPE                    :: kernel_coef_dphdzo
      REALTYPE                    :: kernel_coef_dphfp
  !Dead Zooplankton
      REALTYPE                    :: kernel_coef_dzodzo
      REALTYPE                    :: kernel_coef_dzofp
  !Fecal pellets
      REALTYPE                    :: kernel_coef_fpfp
!SIZE Marine Snow with aggregation
      REALTYPE :: Ratio_P,Ratio_D1,Ratio_D2,Ratio_D3
      REALTYPE :: size_msn_m
!FRAGMENTATION
      REALTYPE                    ::Frag_bio,Frag_phys
      REALTYPE                    ::kolmog,stable_size,Frag_rate
!   Sedimentation rate msn
REALTYPE :: min_w,w_msn_m

!EOP
!-----------------------------------------------------------------------
!BOC
!KBK - is it necessary to initialise every time - expensive in a 3D model
   pp = _ZERO_
   dd = _ZERO_

   do ci=1,nlev
!-----------------------------------------------------------------------------------
!   Light and nutrient limitation factors & Zooplankton and bacterias needed factors
!-----------------------------------------------------------------------------------

!!       ---Light : Platt et al. (1980) - inhibition
      Ps= vp/((alpha/(alpha+inib))*(alpha/(alpha+inib))**(inib/alpha))
      ff= Ps*(1.-exp(-1.*alpha*par(ci)/Ps))*exp(-1.*inib*par(ci)/Ps)
      lumlim1(ci)=ff
!!        ---Nitrate :
      q1=(cc(n,ci)/k1)/(1.+cc(n,ci)/k1+cc(a,ci)/k2)
      nitlim1(ci)=q1
!!        ---Ammonium :
      q2=(cc(a,ci)/k2)/(1.+cc(n,ci)/k1+cc(a,ci)/k2)
      ammlim1(ci)=q2
!!        ---Zooplankton grazing preference normalization factor  
      fac=(cc(z,ci)+z0)/(k3*(r1*cc(p,ci)+r2*cc(b,ci)+  &
             r3*cc(d1,ci)+r4*cc(d2,ci)+r5*cc(d3,ci)+r6*cc(d4,ci))+  &          
                      r1*cc(p,ci)**2+r2*cc(b,ci)**2+   &
             r3*cc(d1,ci)**2+r4*cc(d2,ci)**2+r5*cc(d3,ci)**2+r6*cc(d4,ci)**2)  
!!        --- ???
      min67=min(cc(a,ci),eta*cc(l,ci))  

!-----------------------------------------------------------------------------------
!   Nutrients 
!-----------------------------------------------------------------------------------

      dd(n,p,ci)=ff*q1*(cc(p,ci)+p0)
      dd(a,p,ci)=ff*q2*(cc(p,ci)+p0)
!!    ---Bacteria respiration [Bacteria biomass growth]
      dd(a,b,ci)=vb*min67/(k4+min67+cc(l,ci))*(cc(b,ci)+b0)
      dd(l,b,ci)=vb*cc(l,ci)/(k4+min67+cc(l,ci))*(cc(b,ci)+b0)


!!    ---Condition of [ldon] to allow ldon to become a matrix for the aggregate 
!  ----> Il faudra ajouter plus tard une fonction de turbulence
if (cc(l,ci) .ge. lmin) then                                  
     dd(l,d4,ci)=mldon*cc(l,ci)                            
else                                                    
     dd(l,d4,ci)= 0.0                                         
end if                                                 
!!    ---Nitrification rate 
     dd(a,n,ci)=mu5*cc(a,ci)                                 
      
!-----------------------------------------------------------------------------------
!   Phytoplankton [LOSSES]
!-----------------------------------------------------------------------------------

!!    ---Grazing losses (if beta =1 zooplankton eat everything)
      dd(p,z,ci)=beta*gmax*r1*cc(p,ci)**2*fac

!!    ---Non grazing losses : Excretion
      dd(p,l,ci)=gamma*ff*(q1+q2)*cc(p,ci)

!!    ---Non grazing losses : 
!!            -viral lysis (not taken into acount here)
!!            -internal respiration degradation
!In Moore et al,.2002, all Non grazing losses are estimated at 10% for diatom and small phytoplankton.
     dd(p,d1,ci)=mu1*(cc(p,ci)+p0)/(k5+cc(p,ci)+p0)*cc(p,ci)  &  
                 +(1.-beta)*gmax*r1*cc(p,ci)**2*fac

!!    ---Aggregation losses (See section COLLISION & AGGREGATION PROCESSES)

!-----------------------------------------------------------------------------------
!   Zooplankton [LOSSES]
!-----------------------------------------------------------------------------------

!!    ---Excretion
       dd(z,a,ci)=epsi*mu2*(cc(z,ci)+z0)/(k6+cc(z,ci)+z0)*cc(z,ci)
       dd(z,l,ci)=delta*mu2*(cc(z,ci)+z0)/(k6+cc(z,ci)+z0)*cc(z,ci)
!!    ---Sloppy feeding (z to dph or d1) :Taken into account in dd(p,d1,ci) see above.
!!    ---Fecal pelets
      dd(z,d3,ci)=eg*mu2*(cc(z,ci)+z0)/(k6+cc(z,ci)+z0)*cc(z,ci)
!!    ---Dead Zoo
      dd(z,d2,ci)=(1.-epsi-delta-eg)  &                       
        *mu2*(cc(z,ci)+z0)/(k6+cc(z,ci)+z0)*cc(z,ci) 

!-----------------------------------------------------------------------------------
!   Zooplankton [Diurnal migration]
!               -----------
! As a function of light and [phytoplancton](food)
!-----------------------------------------------------------------------------------

  if (Migra_zoo.eq. 1.0) then  
      if (cc(p,ci) .lt. pmin .or. cc(d1,ci) .lt. dph_initial )  then            
          ws(z,ci) = -1.0*w_zmax*tanh(bertha*(par(ci)-parcrit)) 
      else
          ws(z,ci) = 0.0
      end if
 else
  ws(z,ci) = 0.0
 end if

!-----------------------------------------------------------------------------------
!   Bacterias [LOSSES]
!-----------------------------------------------------------------------------------
!!    ---Bacteria remineralisation    
       dd(b,a,ci)=mu3*cc(b,ci)   
!!    ---Bacteria grazed by zooplankton     
       dd(b,z,ci)=beta*gmax*r2*cc(b,ci)**2*fac
!!    ---Bacteria in aggregate (D4)
       dd(b,d4,ci)=mbac*cc(b,ci)                        
!!    ---Bacteria to detritus-non grazing mortality (D1)
       dd(b,d1,ci)=(1.-beta)*gmax*r2*cc(b,ci)**2*fac   

!-----------------------------------------------------------------------------------
!   Detritus [LOSSES]
!-----------------------------------------------------------------------------------
 
!!    ---Exsudation (see Moore et al., 2002)
      dd(d1,l,ci)=dphlossl*cc(d1,ci)            
      dd(d2,l,ci)=dzolossl*cc(d2,ci)            
      dd(d3,l,ci)=fplossl*cc(d3,ci)             

!!    ---Grazing
      dd(d1,z,ci)=beta*gmax*r3*cc(d1,ci)**2*fac       !broutage-Saprophagie
      dd(d2,z,ci)=beta*gmax*r4*cc(d2,ci)**2*fac       !Carnivorie/cannibalisme/necrophagie
      dd(d3,z,ci)=beta*gmax*r5*cc(d3,ci)**2*fac       !Copprophagy/scatophagie
      dd(d4,z,ci)=beta*gmax*r6*cc(d4,ci)**2*fac       !broutage-Macrophagie


!-------------------------------------------------------------------------------------
!!   Size (radius in m) variation for each particle type 
!-------------------------------------------------------------------------------------

if (size_rand .eq. 1.0) then
!
 call random_number(r_phy)
size_phy=size_phy_us+((size_phy_up-size_phy_us)*r_phy)
   call random_number(r_dph)
size_dph=size_dph_us+((size_dph_up-size_dph_us)*r_dph)
   call random_number(r_dzo)
size_dzo=size_dzo_us+((size_dzo_up-size_dzo_us)*r_dzo)
  call random_number(r_fp)
size_fp=size_fp_us+((size_fp_up-size_fp_us)*r_fp)
   
else
size_phy=size_phy_us
size_dph=size_dph_us
size_dzo=size_dzo_us
size_fp=size_fp_us

endif


!-----------------------------------------------------------------------------------
!   COLLISION & AGGREGATION 
!               -----------
! Read following Documentation at the end of the code
!-----------------------------------------------------------------------------------
!!#1 if (cc(l,ci) .ge. lmin) then   
!!#2   if (Coag_coef .eq. 0.0) then 
!!#3      -if(betaBr .eq. 0.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 0.0)end 
!!#4      -if(betaBr .eq. 1.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 0.0)end
!!            With a condition for constant temperature 
!!#5      -if(betaBr .eq. 0.0 .and. betaSh .eq. 1.0 .and. betaDs .eq. 0.0)end 
!!            With a condition for constant eps 
!!#6      -if(betaBr .eq. 0.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 1.0)end
!!#2   else 
!!       With a condition for constant temperature 
!!       With a condition for constant eps
!!#2   endif    
!!#1 else
!!#1 endif
!-----------------------------------------------------------------------------------

!-------------------------------------------------------------------------------------
!!   Sedimentation rate for each particle type 
!------------------------------------------------------------------------------------- 

if (Phys_w .eq. 0.0 ) then
!Calculated by value from the .nml
 w_p_m   = w_p
 w_dph_m = w_dph
 w_dzo_m = w_dzo
 w_fp_m  = w_fp

else if (Phys_w .eq. 1.0) then
!!-------- Size + physical environement (Stokes's law for all the particles)
!Fluid density
rho_F = rho(ci)
!Difference of densities
Rp = (rho_p-rho_F)
Rdph= (rho_dph-rho_F)
Rdzo =(rho_dzo-rho_F)
Rfp =(rho_fp-rho_F)

!--Phytoplankton
w_p_m=(g*((2*size_phy)**2)*Rp)/(18*dynvis) !Ghosh et al 2013
w_p_m=w_p_m/secs_pr_day 

!--Dead phytoplankton
w_dph_m=(g*((2*size_dph)**2)*Rp)/(18*dynvis) !Ghosh et al 2013
w_dph_m=w_dph_m/secs_pr_day 

!--Dead Zooplankton
w_dzo_m=(g*((2*size_dzo)**2)*Rdzo)/(18*dynvis) !Ghosh et al 2013
w_dzo_m = w_dzo_m/secs_pr_day    

!--Fecal pellets
w_fp_m=(g*((2*size_fp)**2)*Rp)/(18*dynvis) !Ghosh et al 2013
w_fp_m = w_fp_m/secs_pr_day 


else if (Phys_w .eq. 2.0) then
!modified Stoke's law for dzo and fp
!Fluid density
rho_F = rho(ci)
!Difference of densities
Rp = (rho_p-rho_F)
Rdph= (rho_dph-rho_F)
Rdzo =(rho_dzo-rho_F)
Rfp =(rho_fp-rho_F)

!--Phytoplankton (Stoke's law)
w_p_m=(g*((2*size_phy)**2)*Rp)/(18*dynvis) !Ghosh et al 2013
w_p_m=w_p_m/secs_pr_day 

!--Dead phytoplankton(Stoke's law)
w_dph_m=(g*((2*size_dph)**2)*Rp)/(18*dynvis) !Ghosh et al 2013
w_dph_m=w_dph_m/secs_pr_day 

!--Dead Zooplankton(Stoke's law for cylindrical)
w_dzo_m = ((0.079*Rdzo*((4*size_dzo)**2)*g)/dynvis)*((4*size_dzo)/(2*size_dzo))**(-1.664) ! McDonnell et al 2010
w_dzo_m = w_dzo_m/secs_pr_day    

!--Fecal pellets(Stoke's law for cylindrical)
w_fp_m = ((0.079*Rfp*((4*size_fp)**2)*g)/dynvis)*((4*size_fp)/(2*size_fp))**(-1.664) ! McDonnell et al 2010
w_fp_m = w_fp_m/secs_pr_day 

else if (Phys_w .eq. 3.0) then
!----------Calculation of the settling velocity (m/j)/secs_pr_day = m/s - utilisation here of the diameters (size*2)
   !--Phytoplankton
      if (size_phy .gt. 0.001) then
       w_p_m =-(50*((size_phy*2)**0.26))/secs_pr_day ! Alldredge and Gotschalk, 1988.
      else if (size_phy .lt. 0.001 .and. size_phy .gt. 0.0) then
       w_p_m =-(160*((size_phy*2)**0.57))/secs_pr_day  ! Alldredge and Gotschalk, 1988 based on Kajihara 1971.(m/j)
      else
       w_p_m =0.0
      endif

   !--Dead Phytoplankton
      if (size_dph .gt. 0.001) then
      w_dph_m =-(50*((size_dph*2)**0.26))/secs_pr_day ! Alldredge and Gotschalk, 1988.
      else if (size_dph .lt. 0.001 .and. size_dph .gt. 0.0) then
      w_dph_m =-(160*((size_dph*2)**0.57))/secs_pr_day  ! Alldredge and Gotschalk, 1988 based on Kajihara 1971.(m/j)
      else
      w_dph_m =0.0
      endif

   !--Dead Zooplankton
   w_dzo_m =-(160*((size_dzo*2)**0.57))/secs_pr_day ! Personnal assumption from Phy and Dph equation
 !  if(size_dzo .lt. 0.001) then
 !  write(*,*) 'Settling velocity equation for Dzo may not be the right one...'
 !  endif

   !-- Fecal pellets
   !Considering fecals pellets as cylinders, with their diameters D = L/2 (personnal assumption)
   !To follow the equation m need to be put in cm and after put again in m
   !as size_fp_us is the radius, we need to multiply it to have the diameter.
!From : !Komar et al 1981
   !w =(1.21*10³)*L²(L/D)^(⁻1.664) cm/sec

    w_fp_m =(1210)*(((size_fp*100)*4)**2)*(((size_fp*100*4)/(size_fp*100*2))**(-1.664))   
    w_fp_m=-(w_fp_m*0.01)/secs_pr_day  !convertion en m

else
write(*,*) 'No specification for settling velocity of particles,set to nml values'
 w_p_m   = w_p
 w_dph_m = w_dph
 w_dzo_m = w_dzo
 w_fp_m  = w_fp
endif 


!let them settling(m/s)
!The ncdf output do ws(x,ci) *86400 to have  the ouptut in m/j.
ws(p,ci)  = w_p_m
ws(d1,ci) = w_dph_m
ws(d2,ci) = w_dzo_m
ws(d3,ci) = w_fp_m

!Case of marine snow (See below)


!!    ---Condition of the environment to allow collision and aggregation
if (cc(l,ci) .ge. lmin) then  ! #1
!  LEVEL1 'Let"s coagulate buddy ! [LDON Concentration greater than lmin]'

!-------------------------------------------------------------------------------------
!!   Maximum loss for aggregation for each particle type  ! Moore et al.2002
!-------------------------------------------------------------------------------------
!!    ---Phytoplankton 
  pprime=max(cc(p,ci),p0)  
!!    ---Dead Phytoplankton 
  d1rime=max(cc(d1,ci),p0)
!!    ---Dead zooplankton
  d2rime=max(cc(d2,ci),p0)
!!    ---Fecal pellets 
  d3rime=max(cc(d3,ci),p0)

!-------------------------------------------------------------------------------------
!!   Stickiness for each particle type interaction
!-------------------------------------------------------------------------------------

if(sti_cst .eq. 1.0) then ! #1.2
     !Stickiness equal the value given in the nml.
         sti_2p(ci)    = stip_p
         sti_pdph(ci)  = stip_dph
         sti_pdzo(ci)  = stip_dzo
         sti_pfp(ci)   = stip_fp 
         sti_2dph(ci)  = stidph_dph
         sti_dphdzo(ci)= stidph_dzo
         sti_dphfp(ci) = stidph_fp
         sti_2dzo(ci)  = stidzo_dzo
         sti_dzofp(ci) = stidzo_fp
         sti_2fp(ci)   = stifp_fp

else
!Select a random value for the stickiness

   call random_number(r_phy)
   stip=r_phy
   call random_number(r_dph)
   stidph=r_dph
   call random_number(r_dzo)
   stidzo=r_dzo
  call random_number(r_fp)
   stifp=r_fp

!Kiorboe 1994
  sti_2p(ci)     = 0.5*(stip+stip)
  sti_pdph(ci)   = 0.5*(stip+stidph)
  sti_pdzo(ci)   = 0.5*(stip+stidzo)
  sti_pfp(ci)    = 0.5*(stip+stifp)
  sti_2dph(ci)   = 0.5*(stidph+stidph)
  sti_dphdzo(ci) = 0.5*(stidph+stidzo)
  sti_dphfp(ci)  = 0.5*(stidph+stifp)
  sti_2dzo(ci)   = 0.5*(stidzo+stidzo)
  sti_dzofp(ci)  = 0.5*(stidzo+stifp)
  sti_2fp(ci)    = 0.5*(stifp+stifp)

endif  ! #1.2

     if (Coag_coef .eq. 0.0) then !#2
!-------------------------------------------------------------------------------------
!        LEVEL2 'No physical coagulation happens here [Constant Beta are set]'
!-------------------------------------------------------------------------------------
             if(betaBr .eq. 0.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 0.0) then  ! #3
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 1 : Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
 !!    ---A - Aggregation with itself
    coli_pp_NoPhys=sti_2p(ci)*betap_p*cc(p,ci)*cc(p,ci)
    agg_pp=min((txloss_p*pprime),coli_pp_NoPhys)
!!    ---B - Aggregation with dead phytoplankton
   coli_pdph_NoPhys=sti_pdph(ci)*betap_dph*cc(p,ci)*cc(d1,ci)
   agg_pdph=min((txloss_p*pprime),coli_pdph_NoPhys)
!!    ---C - Aggregation with dead zooplankton
   coli_pdzo_NoPhys=sti_pdzo(ci)*betap_dzo*cc(p,ci)*cc(d2,ci)
   agg_pdzo=min((txloss_p*pprime),coli_pdzo_NoPhys)
!!    ---D - Aggregation with Fecal pellets
   coli_pfp_NoPhys=sti_pfp(ci)*betap_fp*cc(p,ci)*cc(d3,ci)
   agg_pfp=min((txloss_p*pprime),coli_pfp_NoPhys)

!*********
dd(p,d4,ci)= (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 2 : Dead Phytoplankton loss by aggregation 
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
 !!    ---A - Aggregation with itself
    coli_dphdph_NoPhys=sti_2dph(ci)*betadph_dph*cc(d1,ci)*cc(d1,ci)
    agg_dphdph=min((txloss_dph*d1rime),coli_dphdph_NoPhys)
!!    ---B - Aggregation with dead zooplankton
   coli_dphdzo_NoPhys=sti_dphdzo(ci)*betap_dzo*cc(d1,ci)*cc(d2,ci)
   agg_dphdzo=min((txloss_dph*d1rime),coli_dphdzo_NoPhys)
!!    ---C - Aggregation with Fecal pellets
   coli_dphfp_NoPhys=sti_dphfp(ci)*betadph_fp*cc(d1,ci)*cc(d3,ci)
   agg_dphfp=min((txloss_dph*d1rime),coli_dphfp_NoPhys)

!*********
dd(d1,d4,ci)= (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 3 : Dead Zooplankton loss by aggregation 
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
 !!    ---A - Aggregation with itself
    coli_dzodzo_NoPhys=sti_2dzo(ci)*betadzo_dzo*cc(d2,ci)*cc(d2,ci)
    agg_dzodzo=min((txloss_dzo*d2rime),coli_dzodzo_NoPhys)
!!    ---B - Aggregation with Fecal pellets
   coli_dzofp_NoPhys=sti_dzofp(ci)*betadzo_fp*cc(d2,ci)*cc(d3,ci)
   agg_dzofp=min((txloss_dzo*d2rime),coli_dzofp_NoPhys)

!*********
dd(d2,d4,ci)= (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 4 : Fecal pellets loss by aggregation 
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself
    coli_fpfp_NoPhys=sti_2fp(ci)*betafp_fp*cc(d3,ci)*cc(d3,ci)
    agg_fpfp=min((txloss_fp*d3rime),coli_fpfp_NoPhys)

!*********
dd(d3,d4,ci)= (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)
!*********
endif !#3

!*************************************************************************************
!!    ---Choice from the user to use and study only betaBr for the calculation of the kernel coefficient

!-------------------------------------------------------------------------------------
!LEVEL3 'Nevertheless...I rather prefer Coagulate only with : BetaBR'
!-------------------------------------------------------------------------------------
if(betaBr .eq. 1.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 0.0) then !#4
!-------------------------------------------------------------------------------------
! Usefull data
!-------------------------------------------------------------------------------------

!!    ---Conversion of field C° temperature to K° - description of physic_Br for easier calcul
!LEVEL2 'Temperature bath is dependant of mother-ocean"s mood ! [Temp. variable due to field/physical]'
   T_degK=t(ci)+ 273.15 
   physic_Br = (2*kB*T_degK)/(3*dynvis)

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 1 : Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself
    betaBr_pp=(physic_Br)*(((size_phy+size_phy)**2)/(size_phy*size_phy))
    coli_pp=sti_2p(ci)* betaBr_pp*cc(p,ci)*cc(p,ci)
    agg_pp=min((txloss_p*pprime),coli_pp)
!!    ---B - Aggregation with dead phytoplankton
   betaBr_pdph=(physic_Br)*(((size_phy+size_dph)**2)/(size_phy*size_dph))
   coli_pdph=sti_pdph(ci)*betaBr_pdph*cc(p,ci)*cc(d1,ci)
   agg_pdph=min((txloss_p*pprime),coli_pdph)
!!    ---C - Aggregation with dead zooplankton
   betaBr_pdzo=(physic_Br)*(((size_phy+size_dzo)**2)/(size_phy*size_dzo))
   coli_pdzo=sti_pdzo(ci)*betaBr_pdzo*cc(p,ci)*cc(d2,ci)
   agg_pdzo=min((txloss_p*pprime),coli_pdzo)
!!    ---D - Aggregation with Fecal pellets
   betaBr_pfp=(physic_Br)*(((size_phy+size_fp)**2)/(size_phy*size_fp))
   coli_pfp=sti_pfp(ci)*betaBr_pfp*cc(p,ci)*cc(d3,ci)
   agg_pfp=min((txloss_p*pprime),coli_pfp)

!*********
!!    ---Loss of p to msn
dd(p,d4,ci)= (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 2 : Dead Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself       
     betaBr_dphdph=(physic_Br)*(((size_dph+size_dph)**2)/(size_dph*size_dph))
     coli_dphdph=sti_2dph(ci)*betaBr_dphdph*cc(d1,ci)*cc(d1,ci)
     agg_dphdph=min((txloss_dph*d1rime),coli_dphdph)
!!    ---B - Aggregation with dead zooplankton           
     betaBr_dphdzo=(physic_Br)*(((size_dph+size_dzo)**2)/(size_dph*size_dzo))
     coli_dphdzo=sti_dphdzo(ci)*betaBr_dphdzo*cc(d1,ci)*cc(d2,ci)
     agg_dphdzo=min((txloss_dph*d1rime),coli_dphdzo)
!!    ---C - Aggregation with fecal pellets         
     betaBr_dphfp=(physic_Br)*(((size_dph+size_fp)**2)/(size_dph*size_fp))
     coli_dphfp=sti_dphfp(ci)*betaBr_dphfp*cc(d1,ci)*cc(d3,ci)
     agg_dphfp=min((txloss_dph*d1rime),coli_dphfp)

!*********
!!    ---Loss of D1 or dph to msn
dd(d1,d4,ci)= (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 3 : Dead zoo loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself          
    betaBr_dzodzo=(physic_Br)*(((size_dzo+size_dzo)**2)/(size_dzo*size_dzo))
    coli_dzodzo=sti_2dzo(ci)*betaBr_dzodzo*cc(d2,ci)*cc(d2,ci)
    agg_dzodzo=min((txloss_dzo*d2rime),coli_dzodzo)
!!    ---B - Aggregation with fecal pellets
   betaBr_dzofp=(physic_Br)*(((size_dzo+size_fp)**2)/(size_dzo*size_fp))
   coli_dzofp=sti_dzofp(ci)*betaBr_dzofp*cc(d2,ci)*cc(d3,ci)
   agg_dzofp=min((txloss_dzo*d2rime),coli_dzofp)

!*********
!!    ---Loss of D2 or dzo to msn
dd(d2,d4,ci)= (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 4 : Fecal pellets loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself             
      betaBr_fpfp=(physic_Br)*(((size_fp+size_fp)**2)/(size_fp*size_fp))
      coli_fpfp=sti_2fp(ci)*betaBr_fpfp*cc(d3,ci)*cc(d3,ci)
      agg_fpfp=min((txloss_fp*d3rime),coli_fpfp)

!*********
!!    ---Loss of D3 or fp to msn
dd(d3,d4,ci)= (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)
!*********

endif !#4 

!*************************************************************************************
!!    ---Choice from the user to use and study only betaSh (Curvilinear kernel for turbulence) for the calculation of the kernel coefficient
!-------------------------------------------------------------------------------------
!LEVEL3 'Nevertheless...I rather prefer Coagulate only with : BetaSh'
!-------------------------------------------------------------------------------------
if (betaBr .eq. 0.0 .and. betaSh .eq. 1.0 .and. betaDs .eq. 0.0) then  ! #5

if(eps_const .eq. 1.0) then
!LEVEL4 'Go and shake up the bath by an EPS constant value'
 bio_eps= eps_n
else
!LEVEL4 'Go and shake up the bath by an EPS obtains via physical environment'
 bio_eps=eps(ci)
endif

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 1 : Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself
   q_pp=(min(size_phy,size_phy))/(max(size_phy,size_phy))
betaSh_pp=9.8*((q_pp**2)/(1+2*q_pp**2))*(sqrt(bio_eps/kinvis))*(size_phy+size_phy)**3
    coli_pp=sti_2p(ci)*betaSh_pp*cc(p,ci)*cc(p,ci)
    agg_pp=min((txloss_p*pprime),coli_pp)
!!    ---B - Aggregation with dead phytoplankton
   q_pdph=(min(size_phy,size_dph))/(max(size_phy,size_dph))
betaSh_pdph=9.8*((q_pdph**2)/(1+2*q_pdph**2))*(sqrt(bio_eps/kinvis))*(size_phy+size_dph)**3
   coli_pdph=sti_pdph(ci)*betaSh_pdph*cc(p,ci)*cc(d1,ci)
   agg_pdph=min((txloss_p*pprime),coli_pdph)
!!    ---C - Aggregation with dead zooplankton
   q_pdzo=(min(size_phy,size_dzo))/(max(size_phy,size_dzo))
betaSh_pdzo=9.8*((q_pdzo**2)/(1+2*q_pdzo**2))*(sqrt(bio_eps/kinvis))*(size_phy+size_dzo)**3
   coli_pdzo=sti_pdzo(ci)*betaSh_pdzo*cc(p,ci)*cc(d2,ci)
   agg_pdzo=min((txloss_p*pprime),coli_pdzo)
!!    ---D - Aggregation with Fecal pellets
   q_pfp=(min(size_phy,size_fp))/(max(size_phy,size_fp))
betaSh_pfp=9.8*((q_pfp**2)/(1+2*q_pfp**2))*(sqrt(bio_eps/kinvis))*(size_phy+size_fp)**3
   coli_pfp=sti_pfp(ci)*betaSh_pfp*cc(p,ci)*cc(d3,ci)
   agg_pfp=min((txloss_p*pprime),coli_pfp)

!*********
!!    ---Loss of p to msn
dd(p,d4,ci)= (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 2 : Dead Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself       
   q_dphdph=(min(size_dph,size_dph))/(max(size_dph,size_dph))
betaSh_dphdph=9.8*((q_dphdph**2)/(1+2*q_dphdph**2))*(sqrt(eps(ci)/kinvis))*(size_dph+size_dph)**3
     coli_dphdph=sti_2dph(ci)*betaSh_dphdph*cc(d1,ci)*cc(d1,ci)
     agg_dphdph=min((txloss_dph*d1rime),coli_dphdph)
!!    ---B - Aggregation with dead zooplankton           
   q_dphdzo=(min(size_dph,size_dzo))/(max(size_dph,size_dzo))
betaSh_dphdzo=9.8*((q_dphdzo**2)/(1+2*q_dphdzo**2))*(sqrt(eps(ci)/kinvis))*(size_dph+size_dzo)**3
     coli_dphdzo=sti_dphdzo(ci)*betaSh_dphdzo*cc(d1,ci)*cc(d2,ci)
     agg_dphdzo=min((txloss_dph*d1rime),coli_dphdzo)
!!    ---C - Aggregation with fecal pellets         
   q_dphfp=(min(size_dph,size_fp))/(max(size_dph,size_fp))
betaSh_dphfp=9.8*((q_dphfp**2)/(1+2*q_dphfp**2))*(sqrt(eps(ci)/kinvis))*(size_dph+size_fp)**3
     coli_dphfp=sti_dphfp(ci)*betaSh_dphfp*cc(d1,ci)*cc(d3,ci)
     agg_dphfp=min((txloss_dph*d1rime),coli_dphfp)

!*********
!!    ---Loss of D1 or dph to msn
dd(d1,d4,ci)= (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 3 : Dead zoo loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself          
   q_dzodzo=(min(size_dzo,size_dzo))/(max(size_dzo,size_dzo))
betaSh_dzodzo=9.8*((q_dzodzo**2)/(1+2*q_dzodzo**2))*(sqrt(eps(ci)/kinvis))*(size_dzo+size_dzo)**3
 coli_dzodzo=sti_2dzo(ci)*betaSh_dzodzo*cc(d2,ci)*cc(d2,ci)
    agg_dzodzo=min((txloss_dzo*d2rime),coli_dzodzo)
!!    ---B - Aggregation with fecal pellets
   q_dzofp=(min(size_dzo,size_fp))/(max(size_dzo,size_fp))
betaSh_dzofp=9.8*((q_dzofp**2)/(1+2*q_dzofp**2))*(sqrt(eps(ci)/kinvis))*(size_dzo+size_fp)**3
   coli_dzofp=sti_dzofp(ci)*betaSh_dzofp*cc(d2,ci)*cc(d3,ci)
   agg_dzofp=min((txloss_dzo*d2rime),coli_dzofp)

!*********
!!    ---Loss of D2 or dzo to msn
dd(d2,d4,ci)= (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 4 : Fecal pellets loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself             
   q_fpfp=(min(size_fp,size_fp))/(max(size_fp,size_fp))
betaSh_fpfp=9.8*((q_fpfp**2)/(1+2*q_fpfp**2))*(sqrt(eps(ci)/kinvis))*(size_fp+size_fp)**3
   coli_fpfp=sti_2fp(ci)*betaSh_fpfp*cc(d3,ci)*cc(d3,ci)
      agg_fpfp=min((txloss_fp*d3rime),coli_fpfp)

!*********
!!    ---Loss of D3 or fp to msn
dd(d3,d4,ci)= (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)
!*********

endif ! #5

!*************************************************************************************
!!    ---Choice from the user to use and study only betaDs (curvilinear) for the calculation of the kernel coefficient
!-------------------------------------------------------------------------------------
!LEVEL3 'Nevertheless...I rather prefer Coagulate only with : BetaDs'
!-------------------------------------------------------------------------------------
if (betaBr .eq. 0.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 1.0) then ! #6

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 1 : Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself
!abs_pp=ABS(w_p_m-w_p_m)
!betaDs_pp=0.5*pi*(size_phy**2)*abs_pp
! coli_pp=sti_2p(ci)*betaDs_pp*cc(p,ci)*cc(p,ci)
! agg_pp=(min((txloss_p*pprime),coli_pp))

!!    ---B - Aggregation with dead phytoplankton
 abs_pdph= ABS(w_p_m-w_dph_m)  
betaDs_pdph=0.5*pi*(min(size_phy,size_dph)**2)*abs_pdph
   coli_pdph=sti_pdph(ci)*betaDs_pdph*cc(p,ci)*cc(d1,ci)
   agg_pdph=min((txloss_p*pprime),coli_pdph)
!!    ---C - Aggregation with dead zooplankton
 abs_pdzo= ABS(w_p_m-w_dzo_m)  
 betaDs_pdzo=0.5*pi*(min(size_phy,size_dzo)**2)*abs_pdzo
   coli_pdzo=sti_pdzo(ci)* betaDs_pdzo*cc(p,ci)*cc(d2,ci)
   agg_pdzo=min((txloss_p*pprime),coli_pdzo)
!!    ---D - Aggregation with Fecal pellets
 abs_pfp= ABS(w_p_m-w_fp_m)  
 betaDs_pfp=0.5*pi*(min(size_phy,size_fp)**2)*abs_pfp
   coli_pfp=sti_pfp(ci)*betaDs_pfp*cc(p,ci)*cc(d3,ci)
   agg_pfp=min((txloss_p*pprime),coli_pfp)

!*********
!!    ---Loss of p to msn
!dd(p,d4,ci)=(agg_pp)+ (agg_pdph)+(agg_pdzo)+(agg_pfp)
dd(p,d4,ci)=(agg_pdph)+(agg_pdzo)+(agg_pfp)

!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 2 : Dead Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself       
!abs_dphdph=ABS(w_dph-w_dph)
!betaDs_dphdph=0.5*pi*(size_dph**2)*abs_dphdph
! coli_dphdph=sti_2dph(ci)*betaDs_dphdph*cc(d1,ci)*cc(d1,ci)
! agg_dphdph=(min((txloss_dph*d1rime),coli_dphdph))
!!    ---B - Aggregation with dead zooplankton           
 abs_dphdzo= ABS(w_dph_m-w_dzo_m) 
 betaDs_dphdzo=0.5*pi*(min(size_dph,size_dzo)**2)*abs_dphdzo
     coli_dphdzo=sti_dphdzo(ci)*betaDs_dphdzo*cc(d1,ci)*cc(d2,ci)
     agg_dphdzo=min((txloss_dph*d1rime),coli_dphdzo)
!!    ---C - Aggregation with fecal pellets         
 abs_dphfp= ABS(w_dph_m-w_fp_m) 
 betaDs_dphfp=0.5*pi*(min(size_dph,size_fp)**2)*abs_dphfp
     coli_dphfp=sti_dphfp(ci)*betaDs_dphfp*cc(d1,ci)*cc(d3,ci)
     agg_dphfp=min((txloss_dph*d1rime),coli_dphfp)

!*********
!!    ---Loss of D1 or dph to msn
!dd(d1,d4,ci)= (agg_dphdph)+(agg_pdph)+(agg_dphdzo)+(agg_dphfp)
dd(d1,d4,ci)= (agg_pdph)+(agg_dphdzo)+(agg_dphfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 3 : Dead zoo loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself          
! abs_dzodzo= ABS(w_dzo_m-w_dzo_m) 
! betaDs_dzofp=0.5*pi*(size_dzo**2)*abs_dzodzo
!   coli_dzodzo=sti_2dzo(ci)*betaDs_dzodzo*cc(d2,ci)*cc(d2,ci)
!   agg_dzodzo=min((txloss_dzo*d2rime),coli_dzodzo)
!!    ---B - Aggregation with fecal pellets
 abs_dzofp= ABS(w_dzo_m-w_fp_m) 
 betaDs_dzofp=0.5*pi*(min(size_dzo,size_fp)**2)*abs_dzofp
   coli_dzofp=sti_dzofp(ci)*betaDs_dzofp*cc(d2,ci)*cc(d3,ci)
   agg_dzofp=min((txloss_dzo*d2rime),coli_dzofp)

!*********
!!    ---Loss of D2 or dzo to msn
dd(d2,d4,ci)=(agg_pdzo)+(agg_dphdzo)+(agg_dzofp)
!dd(d2,d4,ci)=(agg_dzodzo)+ (agg_pdzo)+(agg_dphdzo)+(agg_dzofp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 4 : Fecal pellets loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself             
!abs_fpfp=abs(w_fp_m-w_fp_m)
!betaDs_fpfp=0.5*pi*(size_fp**2)*abs_fpfp
! coli_fpfp=sti_2fp(ci)*betaDs_fpfp*cc(d3,ci)*cc(d3,ci)
! agg_fpfp=min((txloss_fp*d3rime),coli_fpfp)
!*********
!!    ---Loss of D3 or fp to msn
!dd(d3,d4,ci)= (agg_fpfp)+(agg_pfp)+(agg_dphfp)+(agg_dzofp)
dd(d3,d4,ci)= (agg_pfp)+(agg_dphfp)+(agg_dzofp)
!*********
endif !#6

!*************************************************************************************
else !#2 (if Coag.Coef .eq. 1.0)
!-------------------------------------------------------------------------------------
!LEVEL3 'Physical Coagulation happens here ![Beta are calculated via physic]'
!-------------------------------------------------------------------------------------

!-------------------------------------------------------------------------------------
! Usefull data
!-------------------------------------------------------------------------------------
!!    ---Conversion of field C° temperature to K°
   T_degK=t(ci)+ 273.15 

!!    ---Determination of the value of eps
if(eps_const .eq. 1.0) then
 bio_eps= eps_n
else
 bio_eps=eps(ci)
endif
!!    ---Determination of physic_Br
   physic_Br = (2*kB*T_degK)/(3*dynvis)

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 1 : Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!!    ---A - Aggregation with itself
betaBr_pp=(physic_Br)*(((size_phy+size_phy)**2)/(size_phy*size_phy))
 q_pp=(min(size_phy,size_phy))/(max(size_phy,size_phy))
betaSh_pp=9.8*((q_pp**2)/(1+2*q_pp**2))*(sqrt(bio_eps/kinvis))*(size_phy+size_phy)**3
!No BDs 

    kernel_coef_pp=betaBr_pp+betaSh_pp
    coli_pp=sti_2p(ci)*kernel_coef_pp*cc(p,ci)*cc(p,ci)
    agg_pp=min((txloss_p*pprime),coli_pp)

!!    ---B - Aggregation with dead phytoplankton
betaBr_pdph=(physic_Br)*(((size_phy+size_dph)**2)/(size_phy*size_dph))
 q_pdph=(min(size_phy,size_dph))/(max(size_phy,size_dph))
betaSh_pdph=9.8*((q_pdph**2)/(1+2*q_pdph**2))*(sqrt(bio_eps/kinvis))*(size_phy+size_dph)**3
 abs_pdph= ABS(w_p_m-w_dph_m)  
betaDs_pdph=(1/2)*pi*(min(size_phy,size_dph)**2)*abs_pdph
    
   kernel_coef_pdph=betaBr_pdph+betaSh_pdph+betaDs_pdph
   coli_pdph=sti_pdph(ci)*kernel_coef_pdph*cc(p,ci)*cc(d1,ci)
   agg_pdph=min((txloss_p*pprime),coli_pdph)

!!    ---C - Aggregation with dead zooplankton
betaBr_pdzo=(physic_Br)*(((size_phy+size_dzo)**2)/(size_phy*size_dzo))
 q_pdzo=(min(size_phy,size_dzo))/(max(size_phy,size_dzo))
betaSh_pdzo=9.8*((q_pdzo**2)/(1+2*q_pdzo**2))*(sqrt(bio_eps/kinvis))*(size_phy+size_dzo)**3
 abs_pdzo= ABS(w_p_m-w_dzo_m)  
betaDs_pdzo=(1/2)*pi*(min(size_phy,size_dzo)**2)*abs_pdzo

    kernel_coef_pdzo=betaBr_pdzo+betaSh_pdzo+betaDs_pdzo
    coli_pdzo=sti_pdzo(ci)*kernel_coef_pdzo*cc(p,ci)*cc(d2,ci)
    agg_pdzo=min((txloss_p*pprime),coli_pdzo)

!!    ---D - Aggregation with Fecal pellets
betaBr_pfp=(physic_Br)*(((size_phy+size_fp)**2)/(size_phy*size_fp))
 q_pfp=(min(size_phy,size_fp))/(max(size_phy,size_fp))
betaSh_pfp=9.8*((q_pfp**2)/(1+2*q_pfp**2))*(sqrt(eps(ci)/kinvis))*(size_phy+size_fp)**3
 abs_pfp= ABS(w_p_m-w_fp_m)  
betaDs_pfp=(1/2)*pi*(min(size_phy,size_fp)**2)*abs_pfp
    
    kernel_coef_pfp=betaBr_pfp+betaSh_pfp+betaDs_pfp
    coli_pfp=sti_pfp(ci)*kernel_coef_pfp*cc(p,ci)*cc(d3,ci)
    agg_pfp=min((txloss_p*pprime),coli_pfp)

!*********
!!    ---Loss of p to msn
dd(p,d4,ci)= (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 2 : Dead Phytoplankton loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------

!!    ---A - Aggregation with itself       
betaBr_dphdph=(physic_Br)*(((size_dph+size_dph)**2)/(size_dph*size_dph))
   q_dphdph=(min(size_dph,size_dph))/(max(size_dph,size_dph))
betaSh_dphdph=9.8*((q_dphdph**2)/(1+2*q_dphdph**2))*(sqrt(bio_eps/kinvis))*(size_dph+size_dph)**3
!No BDs 

    kernel_coef_dphdph=betaBr_dphdph+betaSh_dphdph
     coli_dphdph=sti_2dph(ci)*kernel_coef_dphdph*cc(d1,ci)*cc(d1,ci)
     agg_dphdph=min((txloss_dph*d1rime),coli_dphdph)

!!    ---B - Aggregation with dead zooplankton           
betaBr_dphdzo=(physic_Br)*(((size_dph+size_dzo)**2)/(size_dph*size_dzo))
   q_dphdzo=(min(size_dph,size_dzo))/(max(size_dph,size_dzo))
betaSh_dphdzo=9.8*((q_dphdzo**2)/(1+2*q_dphdzo**2))*(sqrt(bio_eps/kinvis))*(size_dph+size_dzo)**3
 abs_dphdzo= ABS(w_dph_m-w_dzo_m) 
betaDs_dphdzo=(1/2)*pi*(min(size_dph,size_dzo)**2)*abs_dphdzo

    kernel_coef_dphdzo=betaBr_dphdzo+betaSh_dphdzo+betaDs_dphdzo
     coli_dphdzo=sti_dphdzo(ci)*kernel_coef_dphdzo*cc(d1,ci)*cc(d2,ci)
     agg_dphdzo=min((txloss_dph*d1rime),coli_dphdzo)

!!    ---C - Aggregation with fecal pellets         
betaBr_dphfp=(physic_Br)*(((size_dph+size_fp)**2)/(size_dph*size_fp))
   q_dphfp=(min(size_dph,size_fp))/(max(size_dph,size_fp))
betaSh_dphfp=9.8*((q_dphfp**2)/(1+2*q_dphfp**2))*(sqrt(bio_eps/kinvis))*(size_dph+size_fp)**3
 abs_dphfp= ABS(w_dph_m-w_fp_m) 
betaDs_dphfp=(1/2)*pi*(min(size_dph,size_fp)**2)*abs_dphfp

     kernel_coef_dphfp=betaBr_dphfp+betaSh_dphfp+betaDs_dphfp
     coli_dphfp=sti_dphfp(ci)*kernel_coef_dphfp*cc(d1,ci)*cc(d3,ci)
     agg_dphfp=min((txloss_dph*d1rime),coli_dphfp)

!*********
!!    ---Loss of d1 or dph to msn
dd(d1,d4,ci)= (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 3 : Dead zoo loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------

!!    ---A - Aggregation with itself          
betaBr_dzodzo=(physic_Br)*(((size_dzo+size_dzo)**2)/(size_dzo*size_dzo))
   q_dzodzo=(min(size_dzo,size_dzo))/(max(size_dzo,size_dzo))
betaSh_dzodzo=9.8*((q_dzodzo**2)/(1+2*q_dzodzo**2))*(sqrt(bio_eps/kinvis))*(size_dzo+size_dzo)**3
! No BDs

    kernel_coef_dzodzo=betaBr_dzodzo+betaSh_dzodzo
    coli_dzodzo=sti_2dzo(ci)*kernel_coef_dzodzo*cc(d2,ci)*cc(d2,ci)
    agg_dzodzo=min((txloss_dzo*d2rime),coli_dzodzo)

!!    ---B - Aggregation with fecal pellets
betaBr_dzofp=(physic_Br)*(((size_dzo+size_fp)**2)/(size_dzo*size_fp))
   q_dzofp=(min(size_dzo,size_fp))/(max(size_dzo,size_fp))
betaSh_dzofp=9.8*((q_dzofp**2)/(1+2*q_dzofp**2))*(sqrt(bio_eps/kinvis))*(size_dzo+size_fp)**3
 abs_dzofp= ABS(w_dzo_m-w_fp_m) 
betaDs_dzofp=(1/2)*pi*(min(size_dzo,size_fp)**2)*abs_dzofp

    kernel_coef_dzofp=betaBr_dzofp+betaSh_dzofp+betaDs_dzofp
    coli_dzofp=sti_dzofp(ci)*kernel_coef_dzofp*cc(d2,ci)*cc(d3,ci)
    agg_dzofp=min((txloss_dzo*d2rime),coli_dzofp) 

!*********
!!    ---Loss of D2 or dzo to msn
dd(d2,d4,ci)= (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
!*********

!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Case 4 : Fecal pellets loss by aggregation
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------

!!    ---A - Aggregation with itself             
betaBr_fpfp=(physic_Br)*(((size_fp+size_fp)**2)/(size_fp*size_fp))
   q_fpfp=(min(size_fp,size_fp))/(max(size_fp,size_fp))
betaSh_fpfp=9.8*((q_fpfp**2)/(1+2*q_fpfp**2))*(sqrt(bio_eps/kinvis))*(size_fp+size_fp)**3
!No BDs

    kernel_coef_fpfp=betaBr_fpfp+betaSh_fpfp
    coli_fpfp=sti_2fp(ci)*kernel_coef_fpfp*cc(d3,ci)*cc(d3,ci)
    agg_fpfp=min((txloss_fp*d3rime),coli_fpfp)

!*********
!!    ---Loss of D3 or fp to msn
dd(d3,d4,ci)= (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)
!*********

endif !#2

!!    ---No aggregation due to [LDON] in the environment
else  ! #1  (if cc(l,ci « lmin))

!LEVEL1 'LDON Concentration smaller than lmin'

  dd(p,d4,ci) = 0.0
  dd(d1,d4,ci)= 0.0
  dd(d2,d4,ci)= 0.0
  dd(d3,d4,ci)= 0.0
   
endif !#1

!-----------------------------------------------------------------------------------
!             SIZE Marine Snow with aggregation
!-----------------------------------------------------------------------------------

!----------Flux from particules to msn [mmol/m3/d]
   Flux_P(ci)  = (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
   Flux_D1(ci) = (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
   Flux_D2(ci) =  (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
   Flux_D3(ci) =  (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)

! ---Total Flux received by msn [mmol/m3/d]
     flux_msn(ci) = Flux_P(ci)+Flux_D1(ci)+Flux_D2(ci)+Flux_D3(ci) 

!Calcul of the ratios [-]
     Ratio_P   = Flux_P(ci)/flux_msn(ci)
     Ratio_D1  = Flux_D1(ci)/flux_msn(ci)
     Ratio_D2  = Flux_D2(ci)/flux_msn(ci)
     Ratio_D3  = Flux_D3(ci)/flux_msn(ci)

!----------Selection of place where we have something in the water column to calculate the modified size

! ---Only Phytoplankton 
If (cc(p,ci) .gt. cons_min .and. &
   cc(d1,ci) .lt. cons_min .and. cc(d2,ci) .lt. cons_min .and. cc(d3,ci) .lt. cons_min &
   .and. flux_msn(ci) .gt. min_flux_msn) Then 

    cc(aug_si_d4,ci)=(Ratio_P*size_phy) !Unit of size [m]

! ---Only Dead Phytoplankton 
else If (cc(d1,ci).gt. cons_min &
   .and. cc(p,ci) .lt. cons_min .and. cc(d2,ci) .lt. cons_min .and. cc(d3,ci) .lt. cons_min &
   .and. flux_msn(ci) .gt. min_flux_msn) Then 

    cc(aug_si_d4,ci)= (Ratio_D1*size_dph) !Unit of size [m]

! ---Only Dead Zooplankton 
else If (cc(d2,ci).gt. cons_min &
.and. cc(p,ci) .lt. cons_min .and. cc(d1,ci) .lt. cons_min .and. cc(d3,ci) .lt. cons_min &
 .and. flux_msn(ci) .gt. min_flux_msn) Then 

    cc(aug_si_d4,ci)= (Ratio_D2*size_dzo) !Unit of size [m]

! ---Only fecal pellets
else If (cc(d3,ci).gt. cons_min &
.and. cc(p,ci) .lt. cons_min .and. cc(d1,ci) .lt. cons_min .and. cc(d2,ci) .lt. cons_min &
 .and. flux_msn(ci) .gt. min_flux_msn) Then 
 
  cc(aug_si_d4,ci)= (Ratio_D3*size_fp) !Unit of size [m]

! ---Where we have everything
else If (cc(p,ci) .gt. cons_min .and. cc(d1,ci) .gt. cons_min .and. cc(d2,ci) .gt. cons_min & 
         .and. cc(d3,ci) .gt. cons_min .and. flux_msn(ci) .gt. min_flux_msn) Then 

 cc(aug_si_d4,ci)= (Ratio_P*size_phy)+(Ratio_D1*size_dph)+(Ratio_D2*size_dzo)+(Ratio_D3*size_fp)!Unit of size [m]

else 
  cc(aug_si_d4,ci)= 0.0 !Unit of size [m]

endif

!----------Elaboration of the size variable, available for the next timestep.
if(cc(taille_msn,ci) .eq. 0.0) then
 size_msn_m = cc(aug_si_d4,ci)
 cc(taille_msn,ci) = size_msn_m ! Keep in memory for the next step
else !Calculation of the news size from the previous one + the augmentation calculate via cc(aug_si_d4).
 size_msn_m = cc(taille_msn,ci)+ cc(aug_si_d4,ci)
 cc(taille_msn,ci)= size_msn_m ! Keep in memory for the next step
end if

!-----------------------------------------------------------------------------------
!              FRAGMENTATION
!               -----------
! Read following Documentation at the end of the code

!!    ---Biological Fragmentation - Size reduction = Modification of particle type
!           -- Leackage in dissolved organic matter 
!           -- Bacterial remineralization 
!        Only in the euphotic zone where zooplankton are, following vertical migration:
!           -- Grazing (see before dd(d4,z,ci) = beta*gmax*r6*cc(d4,ci)**2*fac)).
!           -- By swimming zooplankton.
!!    ---Physical Fragmentation  [Alldredge 1990]
!-----------------------------------------------------------------------------------

!Fragmentation will happen 
if (Frag_meth .eq. 1.0) then  !#1

!Flux 
!!    ---Biological Fragmentation
!-----------------------------------------------------------------------------------
!         -- Leackage in dissolved organic matter 
          dd(d4,l,ci)=leak*cc(d4,ci)
!           -- Bacterial remineralization 
          dd(d4,b,ci)=remi*cc(d4,ci)*cc(b,ci)

!Limiting size of msn for physical and biological fragmentation may occur
if (cc(taille_msn,ci) .gt. lim_size ) then ! #2

!Flux
!           -- By swimming zooplankton ! Goldwaith 2005  
         Frag_bio=swim_brk*cc(z,ci)*cc(d4,ci)
! 
!!    ---Physical Fragmentation  
!-----------------------------------------------------------------------------------
!Estimation of the stable_size parameter ! Alldredge 1990
!    -- Kolmogorov microscale of turbulence
        kolmog = (kinvis**3/eps(ci))**0.25
!    -- Value for the stable_size parameter(depending on the diameter)
  if ((cc(taille_msn,ci)*2) .gt. kolmog) then !#3
        stable_size = 1
  else
        stable_size = 0.5
  endif !#3
!Value of the fragmentation rate due to physical processes
   Frag_rate = Floc_coef*(sqrt(eps(ci)/kinvis)**(stable_size))*cc(d4,ci)
   Frag_phys= Frag_rate

!!    ---Calculation of the flux of msn that will return 
!! when fragmentation happen to the "initial boxes" : dph, dzo, fp 
!-----------------------------------------------------------------------------------

!  --The return can happen only if the fragmentation rate is different of 0 otherwise NaN values will be attributed to the dd(d4,x,ci) flux.
 if (Frag_phys+Frag_bio .gt. 0.0 ) then !#4
!Flux
    dd(d4,d1,ci)=  Frag_phys+Frag_bio*cc(d4,ci)* Ratio_D1
    dd(d4,d2,ci)=  Frag_phys+Frag_bio*cc(d4,ci)* Ratio_D2
    dd(d4,d3,ci)=  Frag_phys+Frag_bio*cc(d4,ci)* Ratio_D3
!Size
!----------Elaboration of the size variable, available for the next timestep (the radius will be modified)
          size_msn_m = cc(taille_msn,ci)/2
           if (size_msn_m .lt. 0.0 ) then !#6
              cc(taille_msn,ci)=0.0
           else !#6
              cc(taille_msn,ci)= size_msn_m ! Keep in memory for the next step
           end if !#6
else !#4
!Flux
    dd(d4,d1,ci)= 0.0 
    dd(d4,d2,ci)= 0.0
    dd(d4,d3,ci)= 0.0
!Size
 cc(taille_msn,ci)= cc(taille_msn,ci)
endif !#4

else !#2
!Flux
    dd(d4,d1,ci)= 0.0 
    dd(d4,d2,ci)= 0.0
    dd(d4,d3,ci)= 0.0 

!Size
 cc(taille_msn,ci)= cc(taille_msn,ci)
endif !#2

else !#1
! No flux from msn to other variables
    dd(d4,d1,ci)= 0.0  
    dd(d4,d2,ci)= 0.0
    dd(d4,d3,ci)= 0.0
 
!!On peut de cider qu'ìl y en ai quand meme
    dd(d4,l,ci)=0.0
    dd(d4,b,ci)=0.0

! no size modification
  cc(taille_msn,ci)= cc(taille_msn,ci)

ENDIF !#1



!-------------------------------------------------------------------------------------
!   Sedimentation rate msn
!-------------------------------------------------------------------------------------

!We want to use a calculated settling velocity for the msn

if (w_msnow .eq. 0.0) then  !The one selected by user
  ws(d4,ci)= w_msn
  ws(taille_msn,ci) = ws(d4,ci) 

else if (w_msnow .eq. 1.0) then  ! Stokes law
 w_msn_m=(g*((2*cc(taille_msn,ci))**2)*(rho_msn-rho_F))/(18*dynvis)
 ws(d4,ci) = w_msn_m/secs_pr_day
 ws(taille_msn,ci) = ws(d4,ci)

else if (w_msnow .eq. 2.0) then  
   !----------Calculation of the settling velocity for the msn depending on the previous calculated size
   if (cc(taille_msn,ci).gt. 0.001) then !#3.0
       w_msn_m =-(50*((cc(taille_msn,ci)*2)**0.26))! Alldredge and Gotschalk, 1988.(m/j)
!    else if (cc(taille_msn,ci).lt. 0.001 .and. size_msn_m .gt. 0.0) then
   else if (cc(taille_msn,ci).lt. 0.001 .and. cc(taille_msn,ci) .ne. 0.0) then
       w_msn_m =-(160*((cc(taille_msn,ci)*2)**0.57)) ! Alldredge and Gotschalk, 1988 based on Kajihara 1971.(m/j)
    else
      w_msn_m =0.0
    endif !#3.0
 ws(d4,ci) = w_msn_m/secs_pr_day  
 ws(taille_msn,ci) = ws(d4,ci) 
else
write(*,*) 'No settling velocity choice for msn, value set to 0'
w_msn_m = 0.0
ws(d4,ci) = w_msn_m/secs_pr_day  
ws(taille_msn,ci) = ws(d4,ci) 
endif

!----------Settling velocity send to the advection scheme

!----------Calculation of the min settling velocity for the msn on the water column at (t)
!w_msn_lev(ci) = w_msn_m
!min_w = minval(w_msn_lev(:),dim =1)

!If (cc(p,ci) .gt. cons_min .and. cc(d1,ci) .lt. cons_min .and. cc(d2,ci) .lt. cons_min &
!    .and. cc(d3,ci) .lt. cons_min .and. flux_msn(ci) .gt. min_flux_msn) Then  !#4.0
!ws(d4,ci) = w_msn_m/secs_pr_day
!ws(taille_msn,ci) = ws(d4,ci) 

!else If (cc(d1,ci).gt. cons_min .and. cc(p,ci) .lt. cons_min .and. cc(d2,ci) .lt. cons_min  &
!     .and. cc(d3,ci) .lt. cons_min .and. flux_msn(ci) .gt. min_flux_msn) Then 
!ws(d4,ci) = w_msn_m/secs_pr_day
!ws(taille_msn,ci) = ws(d4,ci) 

!else If (cc(d2,ci).gt. cons_min .and. cc(p,ci) .lt. cons_min .and. cc(d1,ci) .lt. cons_min  &
!       .and. cc(d3,ci) .lt. cons_min .and. flux_msn(ci) .gt. min_flux_msn) Then 
!ws(d4,ci) = w_msn_m/secs_pr_day
!ws(taille_msn,ci) = ws(d4,ci) 

!else If (cc(d3,ci).gt. cons_min .and. cc(p,ci) .lt. cons_min .and. cc(d1,ci) .lt. cons_min &
!      .and. cc(d2,ci) .lt. cons_min .and. flux_msn(ci) .gt. min_flux_msn) Then 
!ws(d4,ci) = w_msn_m/secs_pr_day
!ws(taille_msn,ci) = ws(d4,ci) 

!else If (cc(p,ci) .gt. cons_min .and. cc(d1,ci) .gt. cons_min .and. cc(d2,ci) .gt. cons_min &
!     .and. cc(d3,ci) .gt. cons_min .and. flux_msn(ci) .gt. min_flux_msn) Then 
!ws(d4,ci) = w_msn_m/secs_pr_day
!ws(taille_msn,ci) = ws(d4,ci) 

!else
!ws(d4,ci) = min_w/secs_pr_day
!ws(taille_msn,ci) = ws(d4,ci) 

!endif !#4.0


          
!-----------------------------------------------------------------------------------
!      NET PRIMARY PRODUCTION
!-----------------------------------------------------------------------------------
 !orig ppnet(ci) =(dd(a,p,ci)+dd(n,p,ci)-dd(p,d,ci)-dd(p,z,ci)-dd(p,l,ci))*secs_pr_day
       ppnet(ci) =(dd(a,p,ci)+dd(n,p,ci)-dd(p,d1,ci)-dd(p,z,ci)-dd(p,l,ci)-dd(p,d4,ci))*secs_pr_day
!-----------------------------------------------------------------------



!-------------------------------------------------------------------------------------
!    INFORMATIONS BOX
!-------------------------------------------------------------------------------------
if (write_screen.eq. 1.0) then   !#A  

!  Size variation for each particle type
 if (size_rand .eq. 1.0) then
     write(*,*) 'Random size'
 else
   write(*,*) 'Constant size'
 endif
        write(*,*) 'size_phy:', size_phy
        write(*,*) 'size_dph:', size_dph
        write(*,*) 'size_dzo:', size_dzo
        write(*,*) 'size_fp:', size_fp
!Settling velocity
      write(*,*) '----Sedimentation rate-----------------'
      write(*,*) 'rho_F:', rho_F
      write(*,*) ' Value for: w_p',w_p_m
      write(*,*) ' Value for: w_dph',w_dph_m
      write(*,*) ' Value for: w_dzo',w_dzo_m
      write(*,*) ' Value for: w_fp',w_fp_m
      write(*,*) ' Value for: w_msn',w_msn_m
 
if (cc(l,ci) .gt. lmin) then       !#B
write(*,*) '----Aggregation-----------------'
write(*,*) '-------Maximum loss for aggregation-----------------'
write(*,*) ' pprime:',  pprime
write(*,*) ' d1rime:',  d1rime
write(*,*) ' d2rime:',  d2rime
write(*,*) ' d3rime:',  d3rime

!!   Stickiness for each particle type interaction
if(sti_cst .eq. 1.0) then  !#1.2
     write(*,*) '----Cst Stickiness-----------------' 
else
      write(*,*) '----Variable Stickiness-----------------'
endif!#1.2
     write(*,*) ' Value for stip_p', sti_2p(ci)   
     write(*,*) ' Value for stip_dph', sti_pdph(ci)
     write(*,*) ' Value for stip_dzo',  sti_pdzo(ci)
     write(*,*) ' Value for stip_fp',  sti_pfp(ci)
     write(*,*) ' Value for stidph_dph',  sti_2dph(ci)
     write(*,*) ' Value for stidph_dzo',  sti_dphdzo(ci)
     write(*,*) ' Value for stidph_fp',  sti_dphfp(ci)
     write(*,*) ' Value for stidzo_dzo',  sti_2dzo(ci)
     write(*,*) ' Value for stidzo_fp',  sti_dzofp(ci)
     write(*,*) ' Value for stifp_fp',  sti_2fp(ci)


if (Coag_coef .eq. 0.0) then !#2
   if(betaBr .eq. 0.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 0.0) then  ! #3
    write(*,*) '----Sti+Beta constants-----------------'
         write(*,*) 'txloss_p*pprime:', txloss_p*pprime
         write(*,*) 'coli_pp_NoPhys:', coli_pp_NoPhys
         write(*,*)'agg_pp:', agg_pp
         write(*,*) 'coli_pdph_NoPhys:', coli_pdph_NoPhys
         write(*,*)'agg_pdph:', agg_pdph
         write(*,*) 'coli_pdzo_NoPhys:',coli_pdzo_NoPhys
         write(*,*)'agg_pdzo:', agg_pdzo
         write(*,*) 'coli_pfp_NoPhys:', coli_pfp_NoPhys
         write(*,*)'agg_pfp:', agg_pfp
    write(*,*) 'P to d4:', (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dph*d1rime:', txloss_dph*d1rime
         write(*,*) 'coli_dphdph_NoPhys:', coli_dphdph_NoPhys
         write(*,*)'agg_dphdph:', agg_dphdph
         write(*,*) 'coli_dphdzo_NoPhys:', coli_dphdzo_NoPhys
         write(*,*)'agg_dphdzo:', agg_dphdzo
         write(*,*) 'coli_dphfp_NoPhys:',  coli_dphfp_NoPhys
         write(*,*)'agg_dphfp:', agg_dphfp
    write(*,*) 'D1 to d4:', (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dzo*d2rime:', txloss_dzo*d2rime
         write(*,*) 'coli_dzodzo_NoPhys:', coli_dzodzo_NoPhys
         write(*,*)'agg_dzodzo:', agg_dzodzo
         write(*,*) 'coli_dzofp_NoPhys:',coli_dzofp_NoPhys
         write(*,*)'agg_dzofp:', agg_dzofp
    write(*,*) 'D2 to d4:', (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_fp*d3rime:', txloss_fp*d3rime
         write(*,*) 'coli_fpfp_NoPhys:', coli_fpfp_NoPhys
         write(*,*)'agg_fpfp:', agg_fpfp
    write(*,*) 'D3 to d4:', (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)
   endif !#3

   if(betaBr .eq. 1.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 0.0) then !#4
    write(*,*) '----Run with only BR-----------------'
         write(*,*) 'Temp:',T_degK
         write(*,*) 'physic_Br:',physic_Br     
    write(*,*) '----*****-----------------'
         write(*,*) 'txloss_p*pprime:', txloss_p*pprime
         write(*,*) 'coli_pp:', coli_pp
         write(*,*)'agg_pp:', agg_pp
         write(*,*) 'coli_pdph:', coli_pdph
         write(*,*)'agg_pdph:', agg_pdph
         write(*,*) 'coli_pdzo:',coli_pdzo
         write(*,*)'agg_pdzo:', agg_pdzo
         write(*,*) 'coli_pfp:', coli_pfp
         write(*,*)'agg_pfp:', agg_pfp
    write(*,*) 'P to d4:', (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dph*d1rime:', txloss_dph*d1rime
         write(*,*) 'coli_dphdph:', coli_dphdph
         write(*,*)'agg_dphdph:', agg_dphdph
         write(*,*) 'coli_dphdzo:', coli_dphdzo
         write(*,*)'agg_dphdzo:', agg_dphdzo
         write(*,*) 'coli_dphfp:',  coli_dphfp
         write(*,*)'agg_dphfp:', agg_dphfp
    write(*,*) 'D1 to d4:', (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dzo*d2rime:', txloss_dzo*d2rime
         write(*,*) 'coli_dzodzo:', coli_dzodzo
         write(*,*)'agg_dzodzo:', agg_dzodzo
         write(*,*) 'coli_dzofp:',coli_dzofp
         write(*,*)'agg_dzofp:', agg_dzofp
    write(*,*) 'D2 to d4:', (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_fp*d3rime:', txloss_fp*d3rime
         write(*,*) 'coli_fpfp:', coli_fpfp
         write(*,*)'agg_fpfp:', agg_fpfp
    write(*,*) 'D3 to d4:', (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)
   endif !#4

   if (betaBr .eq. 0.0 .and. betaSh .eq. 1.0 .and. betaDs .eq. 0.0) then  ! #5
      write(*,*) '----Run with only BSh-----------------'   
         write(*,*) 'txloss_p*pprime:', txloss_p*pprime
         write(*,*) 'coli_pp:', coli_pp
         write(*,*)'agg_pp:', agg_pp
         write(*,*) 'coli_pdph:', coli_pdph
         write(*,*)'agg_pdph:', agg_pdph
         write(*,*) 'coli_pdzo:',coli_pdzo
         write(*,*)'agg_pdzo:', agg_pdzo
         write(*,*) 'coli_pfp:', coli_pfp
         write(*,*)'agg_pfp:', agg_pfp
    write(*,*) 'P to d4:', (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dph*d1rime:', txloss_dph*d1rime
         write(*,*) 'coli_dphdph:', coli_dphdph
         write(*,*)'agg_dphdph:', agg_dphdph
         write(*,*) 'coli_dphdzo:', coli_dphdzo
         write(*,*)'agg_dphdzo:', agg_dphdzo
         write(*,*) 'coli_dphfp:',  coli_dphfp
         write(*,*)'agg_dphfp:', agg_dphfp
    write(*,*) 'D1 to d4:', (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dzo*d2rime:', txloss_dzo*d2rime
         write(*,*) 'coli_dzodzo:', coli_dzodzo
         write(*,*)'agg_dzodzo:', agg_dzodzo
         write(*,*) 'coli_dzofp:',coli_dzofp
         write(*,*)'agg_dzofp:', agg_dzofp
    write(*,*) 'D2 to d4:', (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_fp*d3rime:', txloss_fp*d3rime
         write(*,*) 'coli_fpfp:', coli_fpfp
         write(*,*)'agg_fpfp:', agg_fpfp
    write(*,*) 'D3 to d4:', (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)
   endif !#5
 
   if (betaBr .eq. 0.0 .and. betaSh .eq. 0.0 .and. betaDs .eq. 1.0) then ! #6
    write(*,*) '----Run with only BDs-----------------'
         write(*,*) 'calculated size phy:', size_phy
         write(*,*) 'calculated size dph:', size_dph
         write(*,*) 'calculated density of p:', rho_p
         write(*,*) 'calculated density of dph:', rho_dph
         write(*,*) 'Settling phy:', w_p_m
         write(*,*) 'Settling dph:', w_dph_m
         write(*,*) 'Settling dzo:', w_dzo_m
         write(*,*) 'Settling fp:', w_fp_m
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_p*pprime:', txloss_p*pprime
         write(*,*) 'Abs (w_p-w_dph):', abs_pdph
         write(*,*) 'betaDs_pdph:',betaDs_pdph
         write(*,*) 'coli_pdph:', coli_pdph
         write(*,*)'agg_pdph:', agg_pdph
         write(*,*) 'Abs (w_p-w_dzo):', abs_pdzo
         write(*,*) 'coli_pdzo:',coli_pdzo
         write(*,*)'agg_pdzo:', agg_pdzo
         write(*,*) 'Abs (w_p-w_fp):', abs_pfp
         write(*,*) 'coli_pfp:', coli_pfp
         write(*,*)'agg_pfp:', agg_pfp
    write(*,*) 'P to d4:', (agg_pdph)+(agg_pdzo)+(agg_pfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dph*d1rime:', txloss_dph*d1rime
         write(*,*) 'Abs (w_dph-w_dzo):', abs_dphdzo
         write(*,*) 'coli_dphdzo:', coli_dphdzo
         write(*,*)'agg_dphdzo:', agg_dphdzo
         write(*,*) 'Abs (w_dph-w_fp):', abs_dphfp
         write(*,*) 'coli_dphfp:',  coli_dphfp
         write(*,*)'agg_dphfp:', agg_dphfp
    write(*,*) 'D1 to d4:', (agg_pdph)+(agg_dphdzo)+(agg_dphfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dzo*d2rime:', txloss_dzo*d2rime
         write(*,*) 'Abs (w_dzo-w_fp):', abs_dzofp
         write(*,*) 'coli_dzofp:',coli_dzofp
         write(*,*)'agg_dzofp:', agg_dzofp
    write(*,*) 'D2 to d4:', (agg_pdzo)+(agg_dphdzo)+(agg_dzofp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_fp*d3rime:', txloss_fp*d3rime
    write(*,*) 'D3 to d4:', (agg_pfp)+(agg_dphfp)+(agg_dzofp)
  endif !#6

else !#2
        write(*,*) 'Temp:',T_degK
         write(*,*) 'physic_Br:',physic_Br  
         write(*,*) 'eps:', bio_eps     
    write(*,*) '----*****-----------------'
         write(*,*) 'txloss_p*pprime:', txloss_p*pprime
         write(*,*) 'coli_pp:', coli_pp
         write(*,*)'agg_pp:', agg_pp
         write(*,*) 'coli_pdph:', coli_pdph
         write(*,*)'agg_pdph:', agg_pdph
         write(*,*) 'coli_pdzo:',coli_pdzo
         write(*,*)'agg_pdzo:', agg_pdzo
         write(*,*) 'coli_pfp:', coli_pfp
         write(*,*)'agg_pfp:', agg_pfp
    write(*,*) 'P to d4:', (agg_pp)+(agg_pdph)+(agg_pdzo)+(agg_pfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dph*d1rime:', txloss_dph*d1rime
         write(*,*) 'coli_dphdph:', coli_dphdph
         write(*,*)'agg_dphdph:', agg_dphdph
         write(*,*) 'coli_dphdzo:', coli_dphdzo
         write(*,*)'agg_dphdzo:', agg_dphdzo
         write(*,*) 'coli_dphfp:',  coli_dphfp
         write(*,*)'agg_dphfp:', agg_dphfp
    write(*,*) 'D1 to d4:', (agg_pdph)+(agg_dphdph)+(agg_dphdzo)+(agg_dphfp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_dzo*d2rime:', txloss_dzo*d2rime
         write(*,*) 'coli_dzodzo:', coli_dzodzo
         write(*,*)'agg_dzodzo:', agg_dzodzo
         write(*,*) 'coli_dzofp:',coli_dzofp
         write(*,*)'agg_dzofp:', agg_dzofp
    write(*,*) 'D2 to d4:', (agg_pdzo)+(agg_dphdzo)+(agg_dzodzo)+(agg_dzofp)
    write(*,*) '-----------------------------'
         write(*,*) 'txloss_fp*d3rime:', txloss_fp*d3rime
         write(*,*) 'coli_fpfp:', coli_fpfp
         write(*,*)'agg_fpfp:', agg_fpfp
    write(*,*) 'D3 to d4:', (agg_pfp)+(agg_dphfp)+(agg_dzofp)+(agg_fpfp)
 write(*,*) '-------------------------'
   write(*,*)'kernel_coef_pp:', kernel_coef_pp
   write(*,*)'kernel_coef_pdph:', kernel_coef_pdph
   write(*,*)'kernel_coef_pdzo:', kernel_coef_pdzo
   write(*,*)'kernel_coef_pfp:', kernel_coef_pfp
   write(*,*)'kernel_coef_dphdph:', kernel_coef_dphdph
   write(*,*)'kernel_coef_dphdzo:', kernel_coef_dphdzo
   write(*,*)'kernel_coef_dphfp:', kernel_coef_dphfp
   write(*,*)'kernel_coef_dzodzo:', kernel_coef_dzodzo
   write(*,*)'kernel_coef_dzofp:', kernel_coef_dzofp
   write(*,*)'kernel_coef_fpfp:', kernel_coef_fpfp

    write(*,*) '-------------------------'
    write(*,*) '-------------------------'
endif !#2

!             SIZE Marine Snow with aggregation
  write(*,*) '----SIZE Marine Snow ----------------'
  write(*,*)'Flux_P', Flux_P(ci)
  write(*,*)'Flux_D1', Flux_D1(ci)
  write(*,*)'Flux_D2', Flux_D2(ci)
  write(*,*)'Flux_D3', Flux_D3(ci)
  write(*,*) 'flux_msn',flux_msn(ci)
  write(*,*) 'Ratio_P:', Ratio_P
  write(*,*) 'Ratio_D1:', Ratio_D1
  write(*,*) 'Ratio_D2:', Ratio_D2
  write(*,*) 'Ratio_D3:', Ratio_D3
 write(*,*) 'News size of msn :', size_msn_m
  write(*,*) ' Size increase:',  cc(aug_si_d4,ci)
  write(*,*) ' Size msn:',  cc(taille_msn,ci)

!FRAGMENTATION
if (Frag_meth .eq. 1.0) then  !#1
write(*,*) '----Fragmentation ----------------'
write(*,*) 'News size of msn :', size_msn_m
write(*,*)'kolmog', kolmog
write(*,*)'Frag_bio', Frag_bio
write(*,*)' Frag_rate',  Frag_rate
write(*,*) 'Frag_phys', Frag_phys
write(*,*) 'dd(d4,d1,ci)', dd(d4,d1,ci)
write(*,*) 'dd(d4,d2,ci)', dd(d4,d2,ci)
write(*,*) 'dd(d4,d3,ci)', dd(d4,d3,ci)
write(*,*) 'dd(d4,l,ci)', dd(d4,l,ci)
write(*,*) 'dd(d4,b,ci)', dd(d4,b,ci)
endif

endif !#B
!   Sedimentation rate msn
 write(*,*) 'Calculate w_msn :', w_msn_m
!      NET PRIMARY PRODUCTION
 write(*,*) 'ppnet(ci) :', ppnet(ci)


write(*,*) '--News Depth or timesteps--'

endif !#A
!-----------------------------------------------------------------------


      do i=1,numc
         do j=1,numc
            pp(i,j,ci)=dd(j,i,ci)
         end do
      end do
   end do

   return
   end subroutine do_bio_polynow
!EOC

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Finish the bio calculations
!
! !INTERFACE:
   subroutine end_bio_polynow
!
! !DESCRIPTION:
!  Nothing done yet --- supplied for completeness.
!
! !USES:
   IMPLICIT NONE
!
! !REVISION HISTORY:
!  Original author(s): Hans Burchard & Karsten Bolding
!
!EOP
!-----------------------------------------------------------------------
!BOC

   return
   end subroutine end_bio_polynow
!EOC

!-----------------------------------------------------------------------

   end module bio_polynow

!-----------------------------------------------------------------------
! Copyright by the GOTM-team under the GNU Public License - www.gnu.org
!-----------------------------------------------------------------------
!
!DOCUMENTATION
!
!
!-----------------------------------------------------------------------
!!-----------------Maximum loss rate
!-----------------------------------------------------------------------
!
!pprime: Term used to limit phyto. mortality at very low biomass levels (see Moore et al.,2002)
! Minimum phyto biomass :
!0.001 mmol C/m3 for small phyto --» 0.00015094 mmol N/m3 (Comm. pers. Irene Schloss)
!0.005 mmol C/m3 for diatoms     --» 0.00075472 mmol N/m3 (Comm. pers. Irene Schloss)
!a minimum aggregation loss of 5% per day is set to account for direct sinking losses for diatoms.
!Otherwise, a maximum aggregation loss of 70% (txloss_) per day is imposed on all phytoplankton size classe.
!!If you choose to represent large phytoplankton please use in the loop: 
! sp_agg=sp_mort2*pprime*pprime/256.0            
! sp_agg=min((0.7*pprime),sp_agg)
! so_agg=max((0.05*pprime),sp_agg)   
!
!
!-----------------------------------------------------------------------
! COLLISION & AGGREGATION
!-----------------------------------------------------------------------
!
!
!Jackson 1990
!Collision rate is a function of sizes of colliding particles, their concentrations, and environmental parameters. Three mechanisms are used to describe particle collisions in aquatic systems.
!-----------------------------------------------------------------------
! The first is Brownian motion
!-----------------------------------------------------------------------
!in which the random motions of particles move some together. Because the diffusivity of particles varies inversely with their radii, small particles move the most and have the greatest collision rates.
!T = Température absolue en degrés K(temperature en degrés celsius récupéré dans bio_var)
!T_degK(ci)=T(ci)+ 273.15 !( On utilise la Température récupérée dans bio_var)
!size = rayons des particules considérées - micro metres
!dynvis= viscosité dynamique - en Pascal seconde (Pa.s = (N/m2).s)(Défini dans la liste des paramètres)(http://www.engineeringtoolbox.com/water-dynamic-kinematic-viscosity-d_596.html et http://www.formules-physique.com/categorie/1133)
!kB= Constante de Boltzmann (= 1.3806488e-23 joules / kelvin)(Défini dans la liste des paramètres)

!                        betaBr=((8*kB*T_degK(ci))/(6*dynvis))*(((size1+size2)**2)/(size1*size2))

!-----------------------------------------------------------------------
! The second collision mechanism is shear, either laminar or turbulent,
!-----------------------------------------------------------------------
! in which differences in fluid velocity cause two particles being carried by the fluid to approach each other and touch. 
!size = rayons des particules considérées - micro metres
!eps=the turbulent dissipation rate (m2.sec-3) - Disponible via bio_var /bio.F90(from Turbulence module).Unité dispo dans ncdfout.(https://www.cfd-online.com/Wiki/Turbulence_dissipation_rate)
!eps fro; physical model will work only if you choose in gotmturb.nml an another model for turbulence calculation than Kpp.Kpp does not provide a value for eps so you will found empty field leading to model to crash. You can choose the second order model as example.
!kinvis= kinematic viscosity (http://www.rheosense.com/basics/viscosity-units)(Défini dans la liste des paramètres)(http://www.engineeringtoolbox.com/water-dynamic-kinematic-viscosity-d_596.html et http://www.formules-physique.com/categorie/1133)

!                           q=(min(size1,size2))/(max(size1,size2))
!                          betaSh=9.8*((q**2)/(1+2*q**2))*(sqrt(eep/kinvis))*(size1+size2)***3

!-----------------------------------------------------------------------
!The third collision mechanism is differential sedimentation,
!-----------------------------------------------------------------------
! in which one particle falls faster than another, overtaking and colliding with it. Because particle fall velocity is usually a function of size, two particles of the same size and specific gravity fall at the same rate and do not overtake each other.
!w = settling velocities

!                         betaDs=(1/2)*pi*min(size1,size2)**2¦w1-w2¦
!-----------------------------------------------------------------------
!Coefficient de Kernel
!-----------------------------------------------------------------------
                         !kernel_coef=betaBr+betaSh+betaDs

! (See Jokulsdottir 2011)
! dd(x,d4,ci)= stidph*betadph*cc(x,ci)

!-----------------------------------------------------------------------
! PARTICLES SIZES
!-----------------------------------------------------------------------

! For settling velocities : read
!Turner, J. T. (2002). Zooplankton fecal pellets, marine snow and sinking phytoplankton blooms. Aquatic microbial ecology, 27(1), 57-102.

!Fecals pellets size:
!Gowing, M. M., & Silver, M. W. (1985). Minipellets: a new and abundant size class of marine fecal pellets. Journal of Marine Research, 43(2), 395-418.
! > to 50 micro.m  --> 50 µm = 0.000050 m

!Phytoplankton size
!Zoe V. Finkel, John Beardall, Kevin J. Flynn, Antonietta Quigg, T. Alwyn V. Rees, John A. Raven; Phytoplankton in a changing world: cell size and elemental stoichiometry. J Plankton Res 2010; 32 (1): 119-137. doi: 10.1093/plankt/fbp098
!2–20 micro m : for the nanoplankton (Phyto)
!20–200 micro m :for  the  microplankton (Zoo)


!-----------------------------------------------------------------------
! Fragmentation
!-----------------------------------------------------------------------
!Goldthwait, S., Yen, J., Brown, J., & Alldredge, A. (2004). Quantification of marine snow fragmentation by swimming euphausiids. Limnology and Oceanography, 49(4), 940-952.
!Euphausiids were capable of fragmenting all aggregate types and produced an
!average of 7.3 daughter particles, with 60% of these daughter particles remaining within the marine snow size class
!(>0.5 mm).

!Alldredge, A. L., Granata, T. C., Gotschalk, C. C., & Dickey, T. D. (1990). The physical strength of marine snow and its implications for particle disaggregation in the ocean. LIMNOLOGY, 35.
!Abiotic fragmentation of large, rapidly sinking aggregates into smaller, suspended particles by
!fluid shear has been suggested as an important process governing the particle size spectrum in the
!ocean and as one explanation for the exponential decrease of particulate flux with depth below the
!euphotic zone.
!Biological processes
!of disaggregation, such as animal grazing, appear far more likely to mediate the size spectrum of
!aggregated particulate matter in the ocean than abiotic fragmentation due to fluid motion.





!Calculate by Stokes Law : settling velocity (m/s)

!w_p_m   =(2*(rho_p-rho_F)*(size_phy**2)*g)/(9*dynvis)
!w_dph_m =(2*(rho_dph-rho_F)*(size_dph**2)*g)/(9*dynvis)
!w_dzo_m =(2*(rho_dzo-rho_F)*(size_dzo**2)*g)/(9*dynvis)
!w_fp_m  =(2*(rho_fp-rho_F)*(size_fp**2)*g)/(9*dynvis)




!http://infohost.nmt.edu/tcc/help/lang/fortran/scaling.html
!https://stackoverflow.com/questions/23057213/how-to-generate-integer-random-number-in-fortran-90-in-the-range-0-5