| 571 | |
| 572 | == Merging CN-CAN into the trunk == |
| 573 | In 2016 the CAN functionality was added to the CN branch with revision 3238. The end of CN branch is revision 5638. The first update of the CN-CAN branch incorporates the changes what were done to the CN branch between revision 3238 and 5638. Note that this already includes most of the changes done on the trunk because revision 5638 of the CN branch is mostly up to date with the trunk. |
| 574 | |
| 575 | The path of the working version, this is the merge prepared by svn, is located at: |
| 576 | /ccc/work/cont003/gen6328/p86ghatt/ORCHIDEE_OL/CN-CAN/modipsl-cn-can/modeles/ORCHIDEE. The working version was created with the following command: svn merge --dry-run -r 3238:5638 svn://forge.ipsl.jussieu.fr/orchidee/branches/ORCHIDEE-CN --accept postpone |
| 577 | |
| 578 | svn identified 67 files that were in conflict and 22 files that were present in one but absent in the other version. All files where svn identified conflicts as well as some files where we expected some conflicts or code that required some attention where merged manually. Whenever possible the version of CN was copied and the changes done in CN-CAN were integrated. For several of the stomate routine, the opposite approach was used. |
| 579 | |
| 580 | === Tickets === |
| 581 | Not all problems could be solved on the fly. So the following TICKETS still need to be taken care of: |
| 582 | |
| 583 | * woodharvest.f90 is no longer called in CN-CAN because CN-CAN has a different approach to woodharvest. The approach proposed in woodharvest could be added to the merge but this will require some developments. The model will then have two approaches to quantify the effects of forestry. It was decided to delete all variables related to woodharvest.f90. When needed this functionality will have to be added to the merge. |
| 584 | |
| 585 | * Several stomate routines. atm_to_bm has a dimension for icarbon and one for initrogen and replaces co2_to_bm_dgvm and n_to_bm. During the merge co2_to_bm_radia is not kept. During the merge it was not clear what co2_to_bm_radia was needed for. For consistency with the trunk, atm_to_bm_daily was created in stomate and passed into stomate_lpj instead of atm_to_bm. It needs to be tested whether this causes mass balance closure errors. |
| 586 | |
| 587 | * stomate_resp.f90. While merging we spotted a difference in the calculation of gtemp. On version has a factor dt/one_day the other does not. The CN version has simulated very high Ra values whereas that behavior has not yet been observed with the CN-CAN version. More limited testing of CN-CAN could be the cause as could be this difference in code. The change was made in CN-CAN rev3756. Test the effect of this difference between both versions. |
| 588 | |
| 589 | * Several stomate routines. The variable that CN-CAN calls humrel_growingseason is called moiavail_growingseason in the CN branch. The change of this variable name when being passed from one routine to another is confusing. We should keep the code with the fewest different number of variable names. |
| 590 | |
| 591 | * stomate_lpj.f90 and stomate.f90. In these modules fco2_lu and several related variables are calculated and written to the history files. In CN-CAN several of the variables needed to calculate these output variables changes names. Also an additional short-lived pools and fluxes were added. These calculations must be adjusted to make use of the CN-CAN variables. |
| 592 | |
| 593 | * stomate_lpj.f90 and other stomate routines. In CN the variable harvest_above was an output variable of the subroutine harvest and denoted the harvest from croplands. In the merge, the harvest from croplands is no longer stored in a specific variable but is stored in the variable harvest_pool which stores all the harvest from forest, grasslands and croplands. The variable harvest_above can be removed if the previous issues (fco2_lu and several related variables) is dealt with. |
| 594 | |
| 595 | * stomate_prescribe.f90 and all other stomate modules. The variable EndOfYear should no longer be used. The equivalent variable should be used directly from time module. |
| 596 | |
| 597 | * stomate.f90. In changeset 4996 a block of code was removed from CN that is still present in CAN. It is located towards the end of stomate_main before the WHERE and contains litter(:,:,:,:,initrogen) = zero, som(:,:,:,initrogen) = zero. Nicolas said that if CN_som_litter_longterm(:,:,..)<min_stomate, litter and som should not be o. Moreover this case should not happen ... and so hopefully this block of code is not used anymore, it was added for development. Check and make merge consistent with CN. |
| 598 | |
| 599 | * stomate_phenology.f90. Looks like NVui and SL discovered similar issues with phenology, i.e., no guarantee that there is enough N to allocate all the available C, but proposed very different solutions. I followed CN-CAN and for that reason new_cn_leaf_use, bm_wanted_fleaf, and bm_wanted_n_fleaf were not used in the merged. SL estimates that over 50% of the code in of phenology is different between CN and CAN because it had to deal with the diameter classes. So, it is more like a rewrite than a real merge although the functionality should be same. CN has some code to deal with plant mortality under extreme cases. In the merge a placeholder was kept for this code but the code itself was not integrated as it should be rewritten to account for the diameter classes. An ipslerr was added to warn the user if the code would be needed after all. Nvui should check the code to ensure his ideas and concerns were retained. |
| 600 | |
| 601 | * All DGVM modules were copied from CN: lpj_constraints.f90, lpj_crown.f90, lpj_fire.f90, lpj_kill.f90, lpj_pftinout.f90, lpj_cover.f90, lpj_establish.f90, lpj_gap.f90, and lpj_light.f90. Some of the functionality of these routines has probably been reinvented in CAN (e.g., recruitment, gap clean, anthropogenic species changes) so it would be nice to make use of these ideas/code to better integrate the DGVM in stomate.f90. The rest of this code will need to be adjusted so it can deal with more than one diameter class. This requires new developments. |
| 602 | |
| 603 | * stomate_io.f90. In CAN veget_max is an in argument from stomate to readstart but in stomate_io it is called veget_cov_max. This looks like a bug and it should be fixed towards veget_cov_max. |
| 604 | |
| 605 | * stomate_litter.f90. JG merged the code. Modifications of litterfrac, lignin_struc_inc and lignin_wood_inc follow r4164 and r4998 of the CN branch. It needs to be checked whether we want to keep those changes or whether we want to keep the code of CAN. |
| 606 | |
| 607 | * calculate_z_level_photo. Revise the use of printlev_loc in this module. |
| 608 | |
| 609 | * slowproc.f90 and sechiba.f90. Cleaning opportunity: height is calculated in slowproc but lai is calculated in sechiba. Both could be done at the same place as they should not change after stomate. The same applies to veget for which it may also be possible to calculate only once and pass it around in the sechiba subroutines. |
| 610 | |
| 611 | * sechiba.f90 and subroutines: check if nlai still exists. SL thinks it should not be used in CAN. |
| 612 | |
| 613 | * diffuco.f90, diffuco_trans_co2. cimean was taken from http://forge.ipsl.jussieu.fr/orchidee/changeset/3972. NVui verified the code and thinks it is ok but would like to have a better look. |
| 614 | |
| 615 | * enerbil.f90. JG would like to make a new module to keep sechiba.f90 clean. |
| 616 | |
| 617 | * enerbil.f90. The version of CAN was copied into the merge. It still needs to be checked whether CN/trunk contains changes that need to be integrated in enerbil.f90. |
| 618 | |
| 619 | * enerbil.f90. In sechiba_mleb_hs t2m, q2m were removed from the input arguments. mleb_diffuco_trans_co2 uses temp_air instead of t2m and use qair instead of q2m. Check whether this is what we really want because in diffuco_trans_co2 temp_soil and qsurf were used. Should diffuco_trans_co2 and mleb_diffuco_trans_co2 use the same drivers? |
| 620 | |
| 621 | * condveg.f90. The diagnostic variables "vegalb_vis" and "vegalb_nir" no longer exist in the merge. They could be added inside albedo_two_stream if needed. Does someone needs this output? |
| 622 | |
| 623 | * condveg.f90. albedo_snow and albedo_glob are module save variables in CAN. This is not needed. They are calculate in albedo_two_stream and could be local. Be aware that albedo_two_stream is called also in the intialization phase so maybe not a good idea. Check, clean or leave as is. |
| 624 | |
| 625 | * condveg.f90. The subroutine read_background_albedo (former condveg_background_albedo) should be moved to the albedo module. |
| 626 | |
| 627 | * condveg.f90. soilalb_bg changed name to bckgrnd_alb previously in CAN. The merge has two different ways to set the background albedo. If this is kept, also change of the variable name in restart file to be consistent. |
| 628 | |
| 629 | * condveg.f90. condveg_frac_snow is calculated differently equations. It needs to be discussed which approach is preferred. The merge now follows the CAN approach but it can go back to the trunk version if wanted. |
| 630 | |
| 631 | * condveg.f90. Changed albdeo_snow to albedo_snow_vis et albedo_snow_nir but this change still needs to be done in xml. |
| 632 | |
| 633 | * interpweight.f90. The code was taken from CN but revisions 4294 and 4295 were not yet integrated in the merged version. |
| 634 | |
| 635 | * interurf.f90. In intersurf_initialize_gather, coszang was added to the interface (this was not the case in CAN where it was a local variable). In the merged version, JG added it to the argument list as an optional variable. If not there, the model will use 0 as its value. Nevertheless, coszang needs to be added in LMDzOR if the merged ORCHIDEE is used in the coupling. |
| 636 | |
| 637 | * mod_orchidee_transfert_para.F90 and mod_orchidee_mpi_transfert.F90. The new subroutines marked by “_l4” must also be developed with _unstructured. |
| 638 | |
| 639 | * vertical_soil.f90.http://forge.ipsl.jussieu.fr/orchidee/changeset/5374/branches/ORCHIDEE-CN-CAN/ORCHIDEE/src_parameters/vertical_soil.f90. A bug correction was done in CAN which was not kept in the merge. Is it really needed? |
| 640 | |
| 641 | * parameters.f90. In CN rho_soil=2700 in constantes_var and used in thermosoil. In CAN rho_soil=1 in enerbil and only used in enerbil. => I rename rho_soil in enerbil to rho_soil_loc. To be checked whether these are indeed different parameters. |
| 642 | |
| 643 | * constantes.f90. The bug on variables species_change_force(overwritten) and fm_change_force(not set default value) that is present in CAN was kept during the merge. This needs to be fixed when this functionality is to be used. |
| 644 | |
| 645 | === Notes === |
| 646 | Not all problems could be solved on the fly. So the following NOTES may come in handy during debugging: |
| 647 | |
| 648 | * sechiba.f90. The variable ksave which is present in CN-CAN is not needed in sechiba. It could be local to hydrol_arch. It was declared as an intent(in) but never calculated! |
| 649 | |
| 650 | * diffuco.f90, diffuco_trans_co2. co2_to_bm is added to this routine, see ticket #419. Because the CN-CAN code closes it mass balance for both C and N, SL hopes this correction is not needed in the merge. |
| 651 | |
| 652 | * diffuco.f90, diffuco_trans_co2. CN trunk uses temp_air/qair but CAN uses temp_sol/qsurf. Note before merge calculation of T_Sco and T_gm used t2m in CAN. This inconsistencies were corrected. |
| 653 | |
| 654 | * slowproc.f90. cn_leaf_init_2D was not allocated or initialized. readcnleaf is not called... JG removed frac_bare because it was not used. Frac_bare is output in hydrol.f90. |
| 655 | |
| 656 | * condveg.f90. JG removed use slowproc. It is not clear why it was there. |
| 657 | |
| 658 | * stomate_turnover.f90 was copied from CAN. Only some small changes from CN were integrated such as using min_stomate instead of zero. Note that some arguments in IF-statements we change to account for the dimensions used in CAN. |
| 659 | |
| 660 | * somate_growth_fun_all.f90. The If loop for impose_cn was taken from the CN branch therefore the structure of the CAN loops have been changed. |
| 661 | |
| 662 | * stomate_lpf.f90. Bug correction: wstress_month, wstress_season were swapped in the call to stomate_lpj. Corrected in the merge. |
| 663 | |
| 664 | * stomate_lpj.f90. The subroutine harvest was removed from stomate_lpj.f90 because in the merge its functionality is included in the subroutine called crop_harvest which is included in a separate module called sapiens_agriculture.f90. |
| 665 | |
| 666 | * stomate_soilcarbon.f90. the merge of som_dynamics started from the version of CN. The merge of som_dynamics started from the version of CN. calculation of n_minerilazation as done in CAN. The merge of nitrogen_dynamics started from the CAN version and integrated changes from CN. fluxtot has dimension also on nvm in CAN. This is not necessary as it is only used local in the nvm loop. Change in calculation of FixNH4 and f_drain as done in CN. nitrification changes, i.e. *(1.0 - anvf(:,m)) is no longer used, follows CN. kn_conv changed as in CN, mu_no3, mu_no2, mu_n2o changed as in CN, denitrification changed as in CN, frac_nh3 changed as in CN, and emm_fac is now a parameter read with getin. Its default value is 0.2 but was set to 1 in nitrogen_dynamics previously. |
| 667 | |
| 668 | * constantes_mtc.f90. The following variables changed values: slainit, Vcmax25_mtc, stress_gs_mtc(from 0 to 1), stress_gm_mtc(from 0 to 1), nue_opt_mtc, height_init_max_mtc, tau_root_mtc, leafagecrit_mtc, k_root_mtc, k_sap_mtc, cn_leaf_init_mtc, alb_bg_modis(F->T), rough_dyn(F->T), sla_dyn(F->T), sandfraction_default, siltfraction_default amd, snowa_aged_mtc etc. were splitted into separate variables for vis/nir. |
| 669 | |
| 670 | * readdim2.f90. The code from the latest CN version was used and we integrated changeset 5657. But one IF (dt_force >=3600 ) was removed from the trunk. This block of code was marked with a CHECK in the merged version. This was discussed with Agnes. The if that was removed in CN but not in CAN was in a section for daily_interpol and therfore dt_force was always greater than 1 hour. |
| 671 | |
| 672 | * constantes.f90. FW_ change name to FWNIT_ as done in rev 4988 of the CN branch. Kept getin LAIMAX for now; it was not originally in CN. Kept IF (impveg) around getin IMPOSE_SOILT as in CN. It was removed from CAN. |
| 673 | |
| 674 | === 30 oct 2018 === |
| 675 | Cleaning see ticket http://forge.ipsl.jussieu.fr/orchidee/ticket/431 |
| 676 | Sur irene, source non modifié : /ccc/work/cont003/gen6328/p86ghatt/ORCHIDEE_OL/modipsl_CN-CAN/config/ORCHIDEE_OL/tLuy1 |
| 677 | En local, en cours de modification : home_local/jgipsl/ORCHIDEE/modipsl-cn-can |
| 678 | Test cas local : |
| 679 | |
| 680 | Done: |
| 681 | choisnel : trunk [5454] CN-CAN [5548] |
| 682 | diffuco_trans with flag STOMATE_OK_CO2 : trunk [5461] CN-CAN[5549] |
| 683 | old snow scheme: trunk rev [5470] CN-CAN [5550] |
| 684 | CHECK_CWRR and CHECK_CWRR2 are merged: trunk [5506]. CN-CAN[5551] |
| 685 | slowproc_interpol and option MAP_PFT_FORMAT=FALSE: trunk [5518] . CN-CAN[5552] |
| 686 | CHECK_WATERBAL removed in the trunk in rev [5454]. CN-CAN[5553] |
| 687 | |
| 688 | === older than 30 oct 2018 === |
| 689 | * commit 3527: slowproc_update : interated possiblity read a PFTmap when having more than 1 age class and when the file don't contain the age classes. The same was done in the DOFOCO branche but it was done outside slowproc_update, in slowproc_main. |
| 690 | |
| 691 | * commit 3482: Resolved problems with initialization and finalization phase due to merge sechiba rev [3479]. This commit makes the model abel to run but no further validation has been done. diffuco : NB NB: added gpp=0 if ok_co2=FALSE; removed q_cdrag from restart as done in the trunk rev 2868; condveg: removed dtradia as input. Instead use dt_sechiba directly from module; removed soilalb_dry and soilalb_wet from argument list to condveg_soilalb. Those variables are module variables and should not be passed as argument inside the module; Protect some prints with printlev >= 4 in stomate_litter and slowproc. |
| 692 | |
| 693 | * commit 3483: Corrected errors in dimensioning in call to restget; no need to initialize to val_exp before restget. restget will do so if the variable was not found in restart file. |
| 694 | |
| 695 | * commit 3481: Cut lines to be able to compile with gfortran. |