|
1 | 1 | module EDTypesMod |
2 | 2 |
|
3 | | - use FatesConstantsMod , only : r8 => fates_r8 |
4 | | - use shr_infnan_mod, only : nan => shr_infnan_nan, assignment(=) |
| 3 | + use FatesConstantsMod, only : r8 => fates_r8 |
| 4 | + use FatesGlobals, only : fates_log |
| 5 | + use shr_infnan_mod, only : nan => shr_infnan_nan, assignment(=) |
5 | 6 |
|
6 | 7 | use FatesHydraulicsMemMod, only : ed_cohort_hydr_type |
7 | 8 | use FatesHydraulicsMemMod, only : ed_patch_hydr_type |
@@ -602,5 +603,215 @@ function get_size_class_index(dbh) result(cohort_size_class) |
602 | 603 | cohort_size_class = count(dbh-sclass_ed.ge.0.0_r8) |
603 | 604 |
|
604 | 605 | end function get_size_class_index |
605 | | - |
| 606 | + |
| 607 | + ! ===================================================================================== |
| 608 | + |
| 609 | + subroutine val_check_ed_vars(currentPatch,var_aliases,return_code) |
| 610 | + |
| 611 | + ! ---------------------------------------------------------------------------------- |
| 612 | + ! Perform numerical checks on variables of interest. |
| 613 | + ! The input string is of the form: 'VAR1_NAME:VAR2_NAME:VAR3_NAME' |
| 614 | + ! ---------------------------------------------------------------------------------- |
| 615 | + |
| 616 | + |
| 617 | + use FatesUtilsMod,only : check_hlm_list |
| 618 | + use FatesUtilsMod,only : check_var_real |
| 619 | + |
| 620 | + ! Arguments |
| 621 | + type(ed_patch_type),intent(in), target :: currentPatch |
| 622 | + character(len=*),intent(in) :: var_aliases |
| 623 | + integer,intent(out) :: return_code ! return 0 for all fine |
| 624 | + ! return 1 if a nan detected |
| 625 | + ! return 10+ if an overflow |
| 626 | + ! return 100% if an underflow |
| 627 | + ! Locals |
| 628 | + type(ed_cohort_type), pointer :: currentCohort |
| 629 | + |
| 630 | + |
| 631 | + ! Check through a registry of variables to check |
| 632 | + |
| 633 | + if ( check_hlm_list(trim(var_aliases),'co_n') ) then |
| 634 | + |
| 635 | + currentCohort => currentPatch%shortest |
| 636 | + do while(associated(currentCohort)) |
| 637 | + call check_var_real(currentCohort%n,'cohort%n',return_code) |
| 638 | + if(.not.(return_code.eq.0)) then |
| 639 | + call dump_site(currentPatch%siteptr) |
| 640 | + call dump_patch(currentPatch) |
| 641 | + call dump_cohort(currentCohort) |
| 642 | + return |
| 643 | + end if |
| 644 | + currentCohort => currentCohort%taller |
| 645 | + end do |
| 646 | + end if |
| 647 | + |
| 648 | + if ( check_hlm_list(trim(var_aliases),'co_dbh') ) then |
| 649 | + |
| 650 | + currentCohort => currentPatch%shortest |
| 651 | + do while(associated(currentCohort)) |
| 652 | + call check_var_real(currentCohort%dbh,'cohort%dbh',return_code) |
| 653 | + if(.not.(return_code.eq.0)) then |
| 654 | + call dump_site(currentPatch%siteptr) |
| 655 | + call dump_patch(currentPatch) |
| 656 | + call dump_cohort(currentCohort) |
| 657 | + return |
| 658 | + end if |
| 659 | + currentCohort => currentCohort%taller |
| 660 | + end do |
| 661 | + end if |
| 662 | + |
| 663 | + if ( check_hlm_list(trim(var_aliases),'pa_area') ) then |
| 664 | + |
| 665 | + call check_var_real(currentPatch%area,'patch%area',return_code) |
| 666 | + if(.not.(return_code.eq.0)) then |
| 667 | + call dump_site(currentPatch%siteptr) |
| 668 | + call dump_patch(currentPatch) |
| 669 | + return |
| 670 | + end if |
| 671 | + end if |
| 672 | + |
| 673 | + |
| 674 | + |
| 675 | + return |
| 676 | + end subroutine val_check_ed_vars |
| 677 | + |
| 678 | + ! ===================================================================================== |
| 679 | + |
| 680 | + subroutine dump_site(csite) |
| 681 | + |
| 682 | + type(ed_site_type),intent(in),target :: csite |
| 683 | + |
| 684 | + |
| 685 | + ! EDTypes is |
| 686 | + |
| 687 | + write(fates_log(),*) '----------------------------------------' |
| 688 | + write(fates_log(),*) ' Site Coordinates ' |
| 689 | + write(fates_log(),*) '----------------------------------------' |
| 690 | + write(fates_log(),*) 'latitude = ', csite%lat |
| 691 | + write(fates_log(),*) 'longitude = ', csite%lon |
| 692 | + write(fates_log(),*) '----------------------------------------' |
| 693 | + return |
| 694 | + |
| 695 | + end subroutine dump_site |
| 696 | + |
| 697 | + ! ===================================================================================== |
| 698 | + |
| 699 | + |
| 700 | + subroutine dump_patch(cpatch) |
| 701 | + |
| 702 | + type(ed_patch_type),intent(in),target :: cpatch |
| 703 | + |
| 704 | + write(fates_log(),*) '----------------------------------------' |
| 705 | + write(fates_log(),*) ' Dumping Patch Information ' |
| 706 | + write(fates_log(),*) ' (omitting arrays) ' |
| 707 | + write(fates_log(),*) '----------------------------------------' |
| 708 | + write(fates_log(),*) 'pa%patchno = ',cpatch%patchno |
| 709 | + write(fates_log(),*) 'pa%age = ',cpatch%age |
| 710 | + write(fates_log(),*) 'pa%age_class = ',cpatch%age_class |
| 711 | + write(fates_log(),*) 'pa%area = ',cpatch%area |
| 712 | + write(fates_log(),*) 'pa%countcohorts = ',cpatch%countcohorts |
| 713 | + write(fates_log(),*) 'pa%ncl_p = ',cpatch%ncl_p |
| 714 | + write(fates_log(),*) 'pa%total_canopy_area = ',cpatch%total_canopy_area |
| 715 | + write(fates_log(),*) 'pa%total_tree_area = ',cpatch%total_tree_area |
| 716 | + write(fates_log(),*) 'pa%canopy_area = ',cpatch%canopy_area |
| 717 | + write(fates_log(),*) 'pa%bare_frac_area = ',cpatch%bare_frac_area |
| 718 | + write(fates_log(),*) 'pa%lai = ',cpatch%lai |
| 719 | + write(fates_log(),*) 'pa%zstar = ',cpatch%zstar |
| 720 | + write(fates_log(),*) 'pa%disturbance_rate = ',cpatch%disturbance_rate |
| 721 | + write(fates_log(),*) '----------------------------------------' |
| 722 | + return |
| 723 | + |
| 724 | + end subroutine dump_patch |
| 725 | + |
| 726 | + ! ===================================================================================== |
| 727 | + |
| 728 | + subroutine dump_cohort(ccohort) |
| 729 | + |
| 730 | + |
| 731 | + type(ed_cohort_type),intent(in),target :: ccohort |
| 732 | + |
| 733 | + write(fates_log(),*) '----------------------------------------' |
| 734 | + write(fates_log(),*) ' Dumping Cohort Information ' |
| 735 | + write(fates_log(),*) '----------------------------------------' |
| 736 | + write(fates_log(),*) 'co%pft = ', ccohort%pft |
| 737 | + write(fates_log(),*) 'co%n = ', ccohort%n |
| 738 | + write(fates_log(),*) 'co%dbh = ', ccohort%dbh |
| 739 | + write(fates_log(),*) 'co%hite = ', ccohort%hite |
| 740 | + write(fates_log(),*) 'co%b = ', ccohort%b |
| 741 | + write(fates_log(),*) 'co%balive = ', ccohort%balive |
| 742 | + write(fates_log(),*) 'co%bdead = ', ccohort%bdead |
| 743 | + write(fates_log(),*) 'co%bstore = ', ccohort%bstore |
| 744 | + write(fates_log(),*) 'co%laimemory = ', ccohort%laimemory |
| 745 | + write(fates_log(),*) 'co%bsw = ', ccohort%bsw |
| 746 | + write(fates_log(),*) 'co%bl = ', ccohort%bl |
| 747 | + write(fates_log(),*) 'co%br = ', ccohort%br |
| 748 | + write(fates_log(),*) 'co%lai = ', ccohort%lai |
| 749 | + write(fates_log(),*) 'co%sai = ', ccohort%sai |
| 750 | + write(fates_log(),*) 'co%gscan = ', ccohort%gscan |
| 751 | + write(fates_log(),*) 'co%leaf_cost = ', ccohort%leaf_cost |
| 752 | + write(fates_log(),*) 'co%canopy_layer = ', ccohort%canopy_layer |
| 753 | + write(fates_log(),*) 'co%canopy_layer_yesterday = ', ccohort%canopy_layer_yesterday |
| 754 | + write(fates_log(),*) 'co%nv = ', ccohort%nv |
| 755 | + write(fates_log(),*) 'co%status_coh = ', ccohort%status_coh |
| 756 | + write(fates_log(),*) 'co%canopy_trim = ', ccohort%canopy_trim |
| 757 | + write(fates_log(),*) 'co%status_coh = ', ccohort%status_coh |
| 758 | + write(fates_log(),*) 'co%excl_weight = ', ccohort%excl_weight |
| 759 | + write(fates_log(),*) 'co%prom_weight = ', ccohort%prom_weight |
| 760 | + write(fates_log(),*) 'co%size_class = ', ccohort%size_class |
| 761 | + write(fates_log(),*) 'co%size_by_pft_class = ', ccohort%size_by_pft_class |
| 762 | + write(fates_log(),*) 'co%gpp_acc_hold = ', ccohort%gpp_acc_hold |
| 763 | + write(fates_log(),*) 'co%gpp_acc = ', ccohort%gpp_acc |
| 764 | + write(fates_log(),*) 'co%gpp_tstep = ', ccohort%gpp_tstep |
| 765 | + write(fates_log(),*) 'co%npp_acc_hold = ', ccohort%npp_acc_hold |
| 766 | + write(fates_log(),*) 'co%npp_tstep = ', ccohort%npp_tstep |
| 767 | + write(fates_log(),*) 'co%npp_acc = ', ccohort%npp_acc |
| 768 | + write(fates_log(),*) 'co%resp_tstep = ', ccohort%resp_tstep |
| 769 | + write(fates_log(),*) 'co%resp_acc = ', ccohort%resp_acc |
| 770 | + write(fates_log(),*) 'co%resp_acc_hold = ', ccohort%resp_acc_hold |
| 771 | + write(fates_log(),*) 'co%npp_leaf = ', ccohort%npp_leaf |
| 772 | + write(fates_log(),*) 'co%npp_froot = ', ccohort%npp_froot |
| 773 | + write(fates_log(),*) 'co%npp_bsw = ', ccohort%npp_bsw |
| 774 | + write(fates_log(),*) 'co%npp_bdead = ', ccohort%npp_bdead |
| 775 | + write(fates_log(),*) 'co%npp_bseed = ', ccohort%npp_bseed |
| 776 | + write(fates_log(),*) 'co%npp_store = ', ccohort%npp_store |
| 777 | + write(fates_log(),*) 'co%rdark = ', ccohort%rdark |
| 778 | + write(fates_log(),*) 'co%resp_m = ', ccohort%resp_m |
| 779 | + write(fates_log(),*) 'co%resp_g = ', ccohort%resp_g |
| 780 | + write(fates_log(),*) 'co%livestem_mr = ', ccohort%livestem_mr |
| 781 | + write(fates_log(),*) 'co%livecroot_mr = ', ccohort%livecroot_mr |
| 782 | + write(fates_log(),*) 'co%froot_mr = ', ccohort%froot_mr |
| 783 | + write(fates_log(),*) 'co%md = ', ccohort%md |
| 784 | + write(fates_log(),*) 'co%leaf_md = ', ccohort%leaf_md |
| 785 | + write(fates_log(),*) 'co%root_md = ', ccohort%root_md |
| 786 | + write(fates_log(),*) 'co%carbon_balance = ', ccohort%carbon_balance |
| 787 | + write(fates_log(),*) 'co%dmort = ', ccohort%dmort |
| 788 | + write(fates_log(),*) 'co%seed_prod = ', ccohort%seed_prod |
| 789 | + write(fates_log(),*) 'co%treelai = ', ccohort%treelai |
| 790 | + write(fates_log(),*) 'co%treesai = ', ccohort%treesai |
| 791 | + write(fates_log(),*) 'co%leaf_litter = ', ccohort%leaf_litter |
| 792 | + write(fates_log(),*) 'co%c_area = ', ccohort%c_area |
| 793 | + write(fates_log(),*) 'co%woody_turnover = ', ccohort%woody_turnover |
| 794 | + write(fates_log(),*) 'co%cmort = ', ccohort%cmort |
| 795 | + write(fates_log(),*) 'co%bmort = ', ccohort%bmort |
| 796 | + write(fates_log(),*) 'co%imort = ', ccohort%imort |
| 797 | + write(fates_log(),*) 'co%fmort = ', ccohort%fmort |
| 798 | + write(fates_log(),*) 'co%hmort = ', ccohort%hmort |
| 799 | + write(fates_log(),*) 'co%isnew = ', ccohort%isnew |
| 800 | + write(fates_log(),*) 'co%dndt = ', ccohort%dndt |
| 801 | + write(fates_log(),*) 'co%dhdt = ', ccohort%dhdt |
| 802 | + write(fates_log(),*) 'co%ddbhdt = ', ccohort%ddbhdt |
| 803 | + write(fates_log(),*) 'co%dbalivedt = ', ccohort%dbalivedt |
| 804 | + write(fates_log(),*) 'co%dbdeaddt = ', ccohort%dbdeaddt |
| 805 | + write(fates_log(),*) 'co%dbstoredt = ', ccohort%dbstoredt |
| 806 | + write(fates_log(),*) 'co%storage_flux = ', ccohort%storage_flux |
| 807 | + write(fates_log(),*) 'co%cfa = ', ccohort%cfa |
| 808 | + write(fates_log(),*) 'co%fire_mort = ', ccohort%fire_mort |
| 809 | + write(fates_log(),*) 'co%crownfire_mort = ', ccohort%crownfire_mort |
| 810 | + write(fates_log(),*) 'co%cambial_mort = ', ccohort%cambial_mort |
| 811 | + write(fates_log(),*) 'co%size_class = ', ccohort%size_class |
| 812 | + write(fates_log(),*) 'co%size_by_pft_class = ', ccohort%size_by_pft_class |
| 813 | + write(fates_log(),*) '----------------------------------------' |
| 814 | + return |
| 815 | + end subroutine dump_cohort |
| 816 | + |
606 | 817 | end module EDTypesMod |
0 commit comments