diff --git a/ED/Template/Template/ED2IN b/ED/Template/Template/ED2IN index 3b1b47fec..c591a2e95 100644 --- a/ED/Template/Template/ED2IN +++ b/ED/Template/Template/ED2IN @@ -276,27 +276,26 @@ $ED_NL !---------------------------------------------------------------------------------------! ! The following variables control whether site-, patch-, and cohort-level time ! ! means and mean sum of squares should be included in the output files or not. ! - ! ! - ! Reasons to add them: ! - ! a. Sub-polygon variables are more comprehensive. ! - ! b. Explore heterogeneity within a polygon and make interesting analysis. ! - ! c. More chances to create cool 3-D plots. ! - ! ! - ! Reasons to NOT add them: ! - ! a. Output files will become much larger! ! - ! b. In regional/coupled runs, the output files will be ridiculously large. ! - ! c. You may fill up the disk. ! - ! d. Other people's job may crash due to insufficient disk space. ! - ! e. You will gain a bad reputation amongst your colleagues. ! - ! f. And it will be entirely your fault. ! - ! ! - ! Either way, polygon-level averages are always included, and so are the instan- ! - ! taneous site-, patch-, and cohort-level variables needed for resuming the run. ! - ! ! - ! IADD_SITE_MEANS -- Add site-level averages to the output (0 = no; 1 = yes) ! - ! IADD_PATCH_MEANS -- Add patch-level averages to the output (0 = no; 1 = yes) ! - ! IADD_COHORT_MEANS -- Add cohort-level averages to the output (0 = no; 1 = yes) ! - ! ! + ! If these options are on, then they provide much more detailed output, but they may ! + ! add a lot of disk space (especially if you want the fast output to have the detailed ! + ! output). ! + ! ! + ! IADD_SITE_MEANS -- Add site-level averages to the output ! + ! IADD_PATCH_MEANS -- Add patch-level averages to the output ! + ! IADD_COHORT_MEANS -- Add cohort-level averages to the output ! + ! ! + ! The options are additive, and the indices below represent the different types of ! + ! output: ! + ! ! + ! 0 -- No detailed output. ! + ! 1 -- Include the level in monthly output (IMOUTPUT and IQOUTPUT) ! + ! 2 -- Include the level in daily output (IDOUTPUT). ! + ! 4 -- Include the level in sub-daily output (IFOUTPUT and IOOUTPUT). ! + ! ! + ! For example, in case you don't want any cohort output, set IADD_COHORT_MEANS to zero. ! + ! In case you want to generate include cohort means to both daily and monthly outputs, ! + ! but not the sub-daily means, set IADD_COHORT_MEANS to 3 (1 + 2). Any combination of ! + ! the above outputs is acceptable (i.e., any number from 0 to 7). ! !---------------------------------------------------------------------------------------! NL%IADD_SITE_MEANS = 1 NL%IADD_PATCH_MEANS = 1 diff --git a/ED/run/ED2IN b/ED/run/ED2IN index 3425598ed..d7f0888b0 100644 --- a/ED/run/ED2IN +++ b/ED/run/ED2IN @@ -275,27 +275,26 @@ $ED_NL !---------------------------------------------------------------------------------------! ! The following variables control whether site-, patch-, and cohort-level time ! ! means and mean sum of squares should be included in the output files or not. ! - ! ! - ! Reasons to add them: ! - ! a. Sub-polygon variables are more comprehensive. ! - ! b. Explore heterogeneity within a polygon and make interesting analysis. ! - ! c. More chances to create cool 3-D plots. ! - ! ! - ! Reasons to NOT add them: ! - ! a. Output files will become much larger! ! - ! b. In regional/coupled runs, the output files will be ridiculously large. ! - ! c. You may fill up the disk. ! - ! d. Other people's jobs may crash due to insufficient disk space. ! - ! e. You will gain a bad reputation amongst your colleagues. ! - ! f. And it will be entirely your fault. ! - ! ! - ! Either way, polygon-level averages are always included, and so are the instan- ! - ! taneous site-, patch-, and cohort-level variables needed for resuming the run. ! - ! ! - ! IADD_SITE_MEANS -- Add site-level averages to the output (0 = no; 1 = yes) ! - ! IADD_PATCH_MEANS -- Add patch-level averages to the output (0 = no; 1 = yes) ! - ! IADD_COHORT_MEANS -- Add cohort-level averages to the output (0 = no; 1 = yes) ! - ! ! + ! If these options are on, then they provide much more detailed output, but they may ! + ! add a lot of disk space (especially if you want the fast output to have the detailed ! + ! output). ! + ! ! + ! IADD_SITE_MEANS -- Add site-level averages to the output ! + ! IADD_PATCH_MEANS -- Add patch-level averages to the output ! + ! IADD_COHORT_MEANS -- Add cohort-level averages to the output ! + ! ! + ! The options are additive, and the indices below represent the different types of ! + ! output: ! + ! ! + ! 0 -- No detailed output. ! + ! 1 -- Include the level in monthly output (IMOUTPUT and IQOUTPUT) ! + ! 2 -- Include the level in daily output (IDOUTPUT). ! + ! 4 -- Include the level in sub-daily output (IFOUTPUT and IOOUTPUT). ! + ! ! + ! For example, in case you don't want any cohort output, set IADD_COHORT_MEANS to zero. ! + ! In case you want to generate include cohort means to both daily and monthly outputs, ! + ! but not the sub-daily means, set IADD_COHORT_MEANS to 3 (1 + 2). Any combination of ! + ! the above outputs is acceptable (i.e., any number from 0 to 7). ! !---------------------------------------------------------------------------------------! NL%IADD_SITE_MEANS = 1 NL%IADD_PATCH_MEANS = 1 diff --git a/ED/src/io/ed_opspec.F90 b/ED/src/io/ed_opspec.F90 index 807ac94b2..e5aa34cf7 100644 --- a/ED/src/io/ed_opspec.F90 +++ b/ED/src/io/ed_opspec.F90 @@ -1396,23 +1396,23 @@ subroutine ed_opspec_misc call opspec_fatal(reason,'opspec_misc') ifaterr = ifaterr +1 end if - if (iadd_site_means < 0 .or. iadd_site_means > 1) then + if (iadd_site_means < 0 .or. iadd_site_means > 7) then write (reason,fmt='(a,1x,i4,a)') & - 'Invalid IADD_SITE_MEANS, it must be 0 (no) or 1 (yes). Yours is set to' & + 'Invalid IADD_SITE_MEANS, it must be between 0 and 7. Yours is set to' & ,iadd_site_means,'...' call opspec_fatal(reason,'opspec_misc') ifaterr = ifaterr +1 end if - if (iadd_patch_means < 0 .or. iadd_patch_means > 1) then + if (iadd_patch_means < 0 .or. iadd_patch_means > 7) then write (reason,fmt='(a,1x,i4,a)') & - 'Invalid IADD_PATCH_MEANS, it must be 0 (no) or 1 (yes). Yours is set to' & + 'Invalid IADD_PATCH_MEANS, it must be between 0 and 7. Yours is set to' & ,iadd_patch_means,'...' call opspec_fatal(reason,'opspec_misc') ifaterr = ifaterr +1 end if - if (iadd_cohort_means < 0 .or. iadd_cohort_means > 1) then + if (iadd_cohort_means < 0 .or. iadd_cohort_means > 7) then write (reason,fmt='(a,1x,i4,a)') & - 'Invalid IADD_COHORT_MEANS, it must be 0 (no) or 1 (yes). Yours is set to' & + 'Invalid IADD_COHORT_MEANS, it must be between 0 and 7. Yours is set to' & ,iadd_cohort_means,'...' call opspec_fatal(reason,'opspec_misc') ifaterr = ifaterr +1 diff --git a/ED/src/memory/ed_state_vars.F90 b/ED/src/memory/ed_state_vars.F90 index fb9f10e02..7d7a96bdf 100644 --- a/ED/src/memory/ed_state_vars.F90 +++ b/ED/src/memory/ed_state_vars.F90 @@ -21585,18 +21585,35 @@ subroutine filltab_polygontype_p21fmean(cpoly,igr,init,var_len,var_len_global,ma !------------------------------------------------------------------------------------! - ! Decide whether to write the sub-daily means to the history file. ! + ! Decide whether to write the sub-daily means to the history and/or the ! + ! analysis files. This depends on whether we are going to write sub-daily means to ! + ! analyses, or whether we are writing daily/monthly averages (in which case we may ! + ! need to save sub-daily averages to history files). ! !------------------------------------------------------------------------------------! - select case (iadd_site_means) - case (0) - return - case (1) + if (btest(iadd_site_means,2)) then + !----- Site averages sought, decide whether or not to write to history. ----------! if (history_fast) then fast_keys = 'hist:anal' else fast_keys = 'anal' end if - end select + !---------------------------------------------------------------------------------! + elseif (iadd_site_means /= 0) then + !---------------------------------------------------------------------------------! + ! Site averages not needed. Write to history only when we are writing ! + ! sub-daily history and saving site-level daily and/or monthly averages. ! + !---------------------------------------------------------------------------------! + if (history_fast) then + fast_keys = 'hist' + else + return + end if + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -21804,21 +21821,39 @@ subroutine filltab_polygontype_p21dmean(cpoly,igr,init,var_len,var_len_global,ma !------------------------------------------------------------------------------------! - ! Decide whether to write the daily means to the history file. ! + ! Decide whether to write the daily means to the history and/or the analysis ! + ! files. This depends on whether we are going to write daily means to analyses, or ! + ! whether we are writing monthly averages (in which case we may need to save daily ! + ! averages to history files). ! !------------------------------------------------------------------------------------! - select case (iadd_site_means) - case (0) - return - case (1) + if (btest(iadd_site_means,1)) then + !----- Site averages sought, decide whether or not to write to history. ----------! if (history_dail) then dail_keys = 'hist:dail' else dail_keys = 'dail' end if - end select + !---------------------------------------------------------------------------------! + elseif (btest(iadd_site_means,0)) then + !---------------------------------------------------------------------------------! + ! Site averages not needed. Write to history only when we are writing ! + ! sub-monthly history and saving site-level monthly averages. ! + !---------------------------------------------------------------------------------! + if (history_dail) then + dail_keys = 'hist' + else + return + end if + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! + !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! ! This part should have only 1-D vectors (nsites). Notice that they all use ! @@ -21994,18 +22029,22 @@ subroutine filltab_polygontype_p21mmean(cpoly,igr,init,var_len,var_len_global,ma !------------------------------------------------------------------------------------! - ! Decide whether to write the monthly means to the history file. ! + ! Decide whether to write the monthly means to the history and/or the analysis ! + ! files. ! !------------------------------------------------------------------------------------! - select case (iadd_site_means) - case (0) - return - case (1) + if (btest(iadd_site_means,0)) then + !----- Site averages sought, decide whether or not to write to history. ----------! if (history_eorq) then eorq_keys = 'hist:mont:dcyc' else eorq_keys = 'mont:dcyc' end if - end select + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -22329,18 +22368,22 @@ subroutine filltab_polygontype_m21(cpoly,igr,init,var_len,var_len_global,max_ptr !------------------------------------------------------------------------------------! - ! Decide whether to write the mean diel to the history file. ! + ! Decide whether to write the mean diel to the history and/or the analysis ! + ! files. ! !------------------------------------------------------------------------------------! - select case (iadd_site_means) - case (0) - return - case (1) + if (btest(iadd_site_means,0)) then + !----- Site averages sought, decide whether or not to write to history. ----------! if (history_eorq) then eorq_keys = 'hist:dcyc' else eorq_keys = 'dcyc' end if - end select + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -24472,18 +24515,35 @@ subroutine filltab_sitetype_p31fmean(csite,igr,init,var_len,var_len_global,max_p !------------------------------------------------------------------------------------! - ! Decide whether to write the sub-daily means to the history file. ! + ! Decide whether to write the sub-daily means to the history and/or the ! + ! analysis files. This depends on whether we are going to write sub-daily means to ! + ! analyses, or whether we are writing daily/monthly averages (in which case we may ! + ! need to save sub-daily averages to history files). ! !------------------------------------------------------------------------------------! - select case (iadd_patch_means) - case (0) - return - case (1) + if (btest(iadd_patch_means,2)) then + !----- Patch averages sought, decide whether or not to write to history. ---------! if (history_fast) then fast_keys = 'hist:anal' else fast_keys = 'anal' end if - end select + !---------------------------------------------------------------------------------! + elseif (iadd_patch_means /= 0) then + !---------------------------------------------------------------------------------! + ! Patch averages not needed. Write to history only when we are writing ! + ! sub-daily history and saving site-level daily and/or monthly averages. ! + !---------------------------------------------------------------------------------! + if (history_fast) then + fast_keys = 'hist' + else + return + end if + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -25049,18 +25109,35 @@ subroutine filltab_sitetype_p31dmean(csite,igr,init,var_len,var_len_global,max_p !------------------------------------------------------------------------------------! - ! Decide whether to write the daily means to the history file. ! + ! Decide whether to write the daily means to the history and/or the analysis ! + ! files. This depends on whether we are going to write daily means to analyses, or ! + ! whether we are writing monthly averages (in which case we may need to save daily ! + ! averages to history files). ! !------------------------------------------------------------------------------------! - select case (iadd_patch_means) - case (0) - return - case (1) + if (btest(iadd_patch_means,1)) then + !----- Patch averages sought, decide whether or not to write to history. ---------! if (history_dail) then dail_keys = 'hist:dail' else dail_keys = 'dail' end if - end select + !---------------------------------------------------------------------------------! + elseif (btest(iadd_patch_means,0)) then + !---------------------------------------------------------------------------------! + ! Patch averages not needed. Write to history only when we are writing ! + ! sub-monthly history and saving site-level monthly averages. ! + !---------------------------------------------------------------------------------! + if (history_dail) then + dail_keys = 'hist' + else + return + end if + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -25700,18 +25777,22 @@ subroutine filltab_sitetype_p31mmean(csite,igr,init,var_len,var_len_global,max_p !------------------------------------------------------------------------------------! - ! Decide whether to write the monthly means to the history file. ! + ! Decide whether to write the monthly means to the history and/or the analysis ! + ! files. ! !------------------------------------------------------------------------------------! - select case (iadd_patch_means) - case (0) - return - case (1) + if (btest(iadd_patch_means,0)) then + !----- Patch averages sought, decide whether or not to write to history. ---------! if (history_eorq) then eorq_keys = 'hist:mont:dcyc' else eorq_keys = 'mont:dcyc' end if - end select + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -26675,18 +26756,22 @@ subroutine filltab_sitetype_m31(csite,igr,init,var_len,var_len_global,max_ptrs,n !------------------------------------------------------------------------------------! - ! Decide whether to write the mean diel to the history file. ! + ! Decide whether to write the mean diel to the history and/or the analysis ! + ! files. ! !------------------------------------------------------------------------------------! - select case (iadd_patch_means) - case (0) - return - case (1) + if (btest(iadd_patch_means,0)) then + !----- Patch averages sought, decide whether or not to write to history. ---------! if (history_eorq) then eorq_keys = 'hist:dcyc' else eorq_keys = 'dcyc' end if - end select + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -27459,6 +27544,9 @@ subroutine filltab_sitetype_p32(csite,igr,init,var_len,var_len_global,max_ptrs,n character(len=str_len) :: fast_keys character(len=str_len) :: dail_keys character(len=str_len) :: eorq_keys + logical :: add_fast + logical :: add_dail + logical :: add_eorq !------------------------------------------------------------------------------------! @@ -27532,304 +27620,434 @@ subroutine filltab_sitetype_p32(csite,igr,init,var_len,var_len_global,max_ptrs,n !------------------------------------------------------------------------------------! - ! Decide whether to write the fast, daily, and monthly means to the history. ! + ! Decide whether to write the fast, daily, and monthly means to the history ! + ! and/or analysis files. ! !------------------------------------------------------------------------------------! select case (iadd_patch_means) case (0) + !----- Nothing to be written. ----------------------------------------------------! return - case (1) - if (history_fast) then - fast_keys = 'hist:anal' + !---------------------------------------------------------------------------------! + case default + !---------------------------------------------------------------------------------! + ! Turn on all the averages. We then disable those that are not needed. ! + !---------------------------------------------------------------------------------! + add_fast = .true. + add_dail = .true. + add_eorq = .true. + !---------------------------------------------------------------------------------! + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the sub-daily means to the history and/or the ! + ! analysis files. This depends on whether we are going to write sub-daily means ! + ! to analyses, or whether we are writing daily/monthly averages (in which case we ! + ! may need to save sub-daily averages to history files). ! + !---------------------------------------------------------------------------------! + if (btest(iadd_patch_means,2)) then + !----- Patch averages sought, decide whether or not to write to history. ------! + if (history_fast) then + fast_keys = 'hist:anal' + else + fast_keys = 'anal' + end if + !------------------------------------------------------------------------------! + elseif (history_fast) then + !------------------------------------------------------------------------------! + ! Patch averages not needed, but we must add them to history because we ! + ! are saving patch-level daily and/or monthly averages. ! + !------------------------------------------------------------------------------! + fast_keys = 'hist' + !------------------------------------------------------------------------------! else - fast_keys = 'anal' + !----- No need to include sub-daily averages. ---------------------------------! + add_fast = .false. + !------------------------------------------------------------------------------! end if - if (history_dail) then - dail_keys = 'hist:dail' + !---------------------------------------------------------------------------------! + + + + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the daily means to the history and/or the analysis ! + ! files. This depends on whether we are going to write daily means to analyses, ! + ! or whether we are writing monthly averages (in which case we may need to save ! + ! daily averages to history files). ! + !---------------------------------------------------------------------------------! + if (btest(iadd_patch_means,1)) then + !----- Patch averages sought, decide whether or not to write to history. ------! + if (history_dail) then + dail_keys = 'hist:dail' + else + dail_keys = 'dail' + end if + !------------------------------------------------------------------------------! + elseif (btest(iadd_patch_means,0) .and. history_dail) then + !------------------------------------------------------------------------------! + ! Patch averages not needed, but we must add them to history because we ! + ! are saving patch-level monthly averages. ! + !------------------------------------------------------------------------------! + dail_keys = 'hist' + !------------------------------------------------------------------------------! else - dail_keys = 'dail' + !----- No need to go include daily variables. ---------------------------------! + add_dail = .false. + !------------------------------------------------------------------------------! end if - if (history_eorq) then - eorq_keys = 'hist:mont:dcyc' + !---------------------------------------------------------------------------------! + + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the mean diel to the history and/or the analysis ! + ! files. ! + !---------------------------------------------------------------------------------! + if (btest(iadd_patch_means,0)) then + !----- Patch averages sought, decide whether or not to write to history. ------! + if (history_eorq) then + eorq_keys = 'hist:mont:dcyc' + else + eorq_keys = 'mont:dcyc' + end if + !------------------------------------------------------------------------------! else - eorq_keys = 'mont:dcyc' + !----- No need to go include daily variables. ---------------------------------! + add_eorq = .false. + !------------------------------------------------------------------------------! end if + !---------------------------------------------------------------------------------! end select !------------------------------------------------------------------------------------! - if (associated(csite%fmean_soil_energy )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%fmean_soil_energy & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_SOIL_ENERGY_PA :32:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Soil internal energy' & - ,'[ J/m3]','(nzg,ipatch)' ) + + !------------------------------------------------------------------------------------! + ! Fast averages block. ! + !------------------------------------------------------------------------------------! + if (add_fast) then + if (associated(csite%fmean_soil_energy )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%fmean_soil_energy & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_SOIL_ENERGY_PA :32:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Soil internal energy' & + ,'[ J/m3]','(nzg,ipatch)' ) + end if + if (associated(csite%fmean_soil_mstpot )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%fmean_soil_mstpot & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_SOIL_MSTPOT_PA :32:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Soil matric potential' & + ,'[ m]','(nzg,ipatch)' ) + end if + if (associated(csite%fmean_soil_water )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%fmean_soil_water & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_SOIL_WATER_PA :32:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Soil water content' & + ,'[ m3/m3]','(nzg,ipatch)' ) + end if + if (associated(csite%fmean_soil_temp )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%fmean_soil_temp & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_SOIL_TEMP_PA :32:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Soil temperature' & + ,'[ K]','(nzg,ipatch)' ) + end if + if (associated(csite%fmean_soil_fliq )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%fmean_soil_fliq & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_SOIL_FLIQ_PA :32:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Soil liquid fraction' & + ,'[ --]','(nzg,ipatch)' ) + end if + if (associated(csite%fmean_smoist_gg )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%fmean_smoist_gg & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_SMOIST_GG_PA :32:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Soil water flux' & + ,'[ kg/m2/s]','(nzg,ipatch)' ) + end if + if (associated(csite%fmean_transloss )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%fmean_transloss & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_TRANSLOSS_PA :32:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Water loss through transpiration' & + ,'[ kg/m2/s]','(nzg,ipatch)' ) + end if + if (associated(csite%fmean_sensible_gg )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%fmean_sensible_gg & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_SENSIBLE_GG_PA :32:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Soil heat flux' & + ,'[ W/m2]','(nzg,ipatch)' ) + end if end if - if (associated(csite%fmean_soil_mstpot )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%fmean_soil_mstpot & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_SOIL_MSTPOT_PA :32:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Soil matric potential' & - ,'[ m]','(nzg,ipatch)' ) + !------------------------------------------------------------------------------------! + + + + + !------------------------------------------------------------------------------------! + ! Daily averages block. ! + !------------------------------------------------------------------------------------! + if (add_dail) then + if (associated(csite%dmean_soil_energy )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%dmean_soil_energy & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_SOIL_ENERGY_PA :32:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Soil internal energy' & + ,'[ J/m3]','(nzg,ipatch)' ) + end if + if (associated(csite%dmean_soil_mstpot )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%dmean_soil_mstpot & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_SOIL_MSTPOT_PA :32:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Soil matric potential' & + ,'[ m]','(nzg,ipatch)' ) + end if + if (associated(csite%dmean_soil_water )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%dmean_soil_water & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_SOIL_WATER_PA :32:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Soil water content' & + ,'[ m3/m3]','(nzg,ipatch)' ) + end if + if (associated(csite%dmean_soil_temp )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%dmean_soil_temp & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_SOIL_TEMP_PA :32:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Soil temperature' & + ,'[ K]','(nzg,ipatch)' ) + end if + if (associated(csite%dmean_soil_fliq )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%dmean_soil_fliq & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_SOIL_FLIQ_PA :32:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Soil liquid fraction' & + ,'[ --]','(nzg,ipatch)' ) + end if + if (associated(csite%dmean_smoist_gg )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%dmean_smoist_gg & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_SMOIST_GG_PA :32:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Soil water flux' & + ,'[ kg/m2/s]','(nzg,ipatch)' ) + end if + if (associated(csite%dmean_transloss )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%dmean_transloss & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_TRANSLOSS_PA :32:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Water loss through transpiration' & + ,'[ kg/m2/s]','(nzg,ipatch)' ) + end if + if (associated(csite%dmean_sensible_gg )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%dmean_sensible_gg & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_SENSIBLE_GG_PA :32:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Soil heat flux' & + ,'[ W/m2]','(nzg,ipatch)' ) + end if end if - if (associated(csite%fmean_soil_water )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%fmean_soil_water & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_SOIL_WATER_PA :32:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Soil water content' & - ,'[ m3/m3]','(nzg,ipatch)' ) + !------------------------------------------------------------------------------------! + + + + + !------------------------------------------------------------------------------------! + ! Monthly averages block. ! + !------------------------------------------------------------------------------------! + if (add_eorq) then + if (associated(csite%mmean_soil_energy )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%mmean_soil_energy & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_SOIL_ENERGY_PA :32:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Soil internal energy' & + ,'[ J/m3]','(nzg,ipatch)' ) + end if + if (associated(csite%mmean_soil_mstpot )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%mmean_soil_mstpot & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_SOIL_MSTPOT_PA :32:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Soil matric potential' & + ,'[ m]','(nzg,ipatch)' ) + end if + if (associated(csite%mmean_soil_water )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%mmean_soil_water & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_SOIL_WATER_PA :32:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Soil water content' & + ,'[ m3/m3]','(nzg,ipatch)' ) + end if + if (associated(csite%mmean_soil_temp )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%mmean_soil_temp & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_SOIL_TEMP_PA :32:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Soil temperature' & + ,'[ K]','(nzg,ipatch)' ) + end if + if (associated(csite%mmean_soil_fliq )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%mmean_soil_fliq & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_SOIL_FLIQ_PA :32:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Soil liquid fraction' & + ,'[ --]','(nzg,ipatch)' ) + end if + if (associated(csite%mmean_smoist_gg )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%mmean_smoist_gg & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_SMOIST_GG_PA :32:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Soil water flux' & + ,'[ kg/m2/s]','(nzg,ipatch)' ) + end if + if (associated(csite%mmean_transloss )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%mmean_transloss & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_TRANSLOSS_PA :32:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Water loss through transpiration' & + ,'[ kg/m2/s]','(nzg,ipatch)' ) + end if + if (associated(csite%mmean_sensible_gg )) then + nvar = nvar+1 + call vtable_edio_r(npts,csite%mmean_sensible_gg & + ,nvar,igr,init,csite%paglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_SENSIBLE_GG_PA :32:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Soil heat flux' & + ,'[ W/m2]','(nzg,ipatch)' ) + end if end if - if (associated(csite%fmean_soil_temp )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%fmean_soil_temp & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_SOIL_TEMP_PA :32:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Soil temperature' & - ,'[ K]','(nzg,ipatch)' ) + !------------------------------------------------------------------------------------! + + return + end subroutine filltab_sitetype_p32 + !=======================================================================================! + !=======================================================================================! + + + + + + + !=======================================================================================! + !=======================================================================================! + ! SUBROUTINE: FILLTAB_SITETYPE_M32 + !> \brief This routine will fill the pointer table with the patch-level variables + !> (sitetype) that have three dimensions (nzg,ndcycle,npatches). + !---------------------------------------------------------------------------------------! + subroutine filltab_sitetype_m32(csite,igr,init,var_len,var_len_global,max_ptrs,nvar) + use ed_var_tables, only : vtable_edio_r & ! sub-routine + , metadata_edio ! ! sub-routine + + implicit none + !----- Arguments. -------------------------------------------------------------------! + type(sitetype) , target :: csite + integer , intent(in) :: init + integer , intent(in) :: igr + integer , intent(in) :: var_len + integer , intent(in) :: max_ptrs + integer , intent(in) :: var_len_global + integer , intent(inout) :: nvar + !----- Local variables. -------------------------------------------------------------! + integer :: npts + character(len=str_len) :: eorq_keys + !------------------------------------------------------------------------------------! + + + + + + !------------------------------------------------------------------------------------! + ! Decide whether to write the mean diel to the history and/or the analysis ! + ! files. ! + !------------------------------------------------------------------------------------! + if (btest(iadd_patch_means,0)) then + !----- Patch averages sought, decide whether or not to write to history. ---------! + if (history_eorq) then + eorq_keys = 'hist:dcyc' + else + eorq_keys = 'dcyc' + end if + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! end if - if (associated(csite%fmean_soil_fliq )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%fmean_soil_fliq & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_SOIL_FLIQ_PA :32:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Soil liquid fraction' & - ,'[ --]','(nzg,ipatch)' ) - end if - if (associated(csite%fmean_smoist_gg )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%fmean_smoist_gg & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_SMOIST_GG_PA :32:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Soil water flux' & - ,'[ kg/m2/s]','(nzg,ipatch)' ) - end if - if (associated(csite%fmean_transloss )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%fmean_transloss & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_TRANSLOSS_PA :32:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Water loss through transpiration' & - ,'[ kg/m2/s]','(nzg,ipatch)' ) - end if - if (associated(csite%fmean_sensible_gg )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%fmean_sensible_gg & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_SENSIBLE_GG_PA :32:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Soil heat flux' & - ,'[ W/m2]','(nzg,ipatch)' ) - end if - if (associated(csite%dmean_soil_energy )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%dmean_soil_energy & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_SOIL_ENERGY_PA :32:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Soil internal energy' & - ,'[ J/m3]','(nzg,ipatch)' ) - end if - if (associated(csite%dmean_soil_mstpot )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%dmean_soil_mstpot & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_SOIL_MSTPOT_PA :32:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Soil matric potential' & - ,'[ m]','(nzg,ipatch)' ) - end if - if (associated(csite%dmean_soil_water )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%dmean_soil_water & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_SOIL_WATER_PA :32:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Soil water content' & - ,'[ m3/m3]','(nzg,ipatch)' ) - end if - if (associated(csite%dmean_soil_temp )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%dmean_soil_temp & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_SOIL_TEMP_PA :32:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Soil temperature' & - ,'[ K]','(nzg,ipatch)' ) - end if - if (associated(csite%dmean_soil_fliq )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%dmean_soil_fliq & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_SOIL_FLIQ_PA :32:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Soil liquid fraction' & - ,'[ --]','(nzg,ipatch)' ) - end if - if (associated(csite%dmean_smoist_gg )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%dmean_smoist_gg & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_SMOIST_GG_PA :32:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Soil water flux' & - ,'[ kg/m2/s]','(nzg,ipatch)' ) - end if - if (associated(csite%dmean_transloss )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%dmean_transloss & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_TRANSLOSS_PA :32:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Water loss through transpiration' & - ,'[ kg/m2/s]','(nzg,ipatch)' ) - end if - if (associated(csite%dmean_sensible_gg )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%dmean_sensible_gg & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_SENSIBLE_GG_PA :32:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Soil heat flux' & - ,'[ W/m2]','(nzg,ipatch)' ) - end if - if (associated(csite%mmean_soil_energy )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%mmean_soil_energy & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_SOIL_ENERGY_PA :32:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Soil internal energy' & - ,'[ J/m3]','(nzg,ipatch)' ) - end if - if (associated(csite%mmean_soil_mstpot )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%mmean_soil_mstpot & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_SOIL_MSTPOT_PA :32:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Soil matric potential' & - ,'[ m]','(nzg,ipatch)' ) - end if - if (associated(csite%mmean_soil_water )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%mmean_soil_water & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_SOIL_WATER_PA :32:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Soil water content' & - ,'[ m3/m3]','(nzg,ipatch)' ) - end if - if (associated(csite%mmean_soil_temp )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%mmean_soil_temp & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_SOIL_TEMP_PA :32:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Soil temperature' & - ,'[ K]','(nzg,ipatch)' ) - end if - if (associated(csite%mmean_soil_fliq )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%mmean_soil_fliq & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_SOIL_FLIQ_PA :32:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Soil liquid fraction' & - ,'[ --]','(nzg,ipatch)' ) - end if - if (associated(csite%mmean_smoist_gg )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%mmean_smoist_gg & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_SMOIST_GG_PA :32:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Soil water flux' & - ,'[ kg/m2/s]','(nzg,ipatch)' ) - end if - if (associated(csite%mmean_transloss )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%mmean_transloss & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_TRANSLOSS_PA :32:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Water loss through transpiration' & - ,'[ kg/m2/s]','(nzg,ipatch)' ) - end if - if (associated(csite%mmean_sensible_gg )) then - nvar = nvar+1 - call vtable_edio_r(npts,csite%mmean_sensible_gg & - ,nvar,igr,init,csite%paglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_SENSIBLE_GG_PA :32:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Soil heat flux' & - ,'[ W/m2]','(nzg,ipatch)' ) - end if - !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! - return - end subroutine filltab_sitetype_p32 - !=======================================================================================! - !=======================================================================================! - - - - - - - !=======================================================================================! - !=======================================================================================! - ! SUBROUTINE: FILLTAB_SITETYPE_M32 - !> \brief This routine will fill the pointer table with the patch-level variables - !> (sitetype) that have three dimensions (nzg,ndcycle,npatches). - !---------------------------------------------------------------------------------------! - subroutine filltab_sitetype_m32(csite,igr,init,var_len,var_len_global,max_ptrs,nvar) - use ed_var_tables, only : vtable_edio_r & ! sub-routine - , metadata_edio ! ! sub-routine - - implicit none - !----- Arguments. -------------------------------------------------------------------! - type(sitetype) , target :: csite - integer , intent(in) :: init - integer , intent(in) :: igr - integer , intent(in) :: var_len - integer , intent(in) :: max_ptrs - integer , intent(in) :: var_len_global - integer , intent(inout) :: nvar - !----- Local variables. -------------------------------------------------------------! - integer :: npts - character(len=str_len) :: eorq_keys - !------------------------------------------------------------------------------------! - - - - !------------------------------------------------------------------------------------! - ! Decide whether to write the mean diel to the history file. ! - !------------------------------------------------------------------------------------! - select case (iadd_patch_means) - case (0) - return - case (1) - if (history_eorq) then - eorq_keys = 'hist:dcyc' - else - eorq_keys = 'dcyc' - end if - end select - !------------------------------------------------------------------------------------! - - - @@ -29522,18 +29740,35 @@ subroutine filltab_patchtype_p41fmean(cpatch,igr,init,var_len,var_len_global,max !------------------------------------------------------------------------------------! - ! Decide whether to write the sub-daily means to the history file. ! + ! Decide whether to write the sub-daily means to the history and/or the ! + ! analysis files. This depends on whether we are going to write sub-daily means to ! + ! analyses, or whether we are writing daily/monthly averages (in which case we may ! + ! need to save sub-daily averages to history files). ! !------------------------------------------------------------------------------------! - select case (iadd_cohort_means) - case (0) - return - case (1) + if (btest(iadd_cohort_means,2)) then + !----- Cohort averages sought, decide whether or not to write to history. --------! if (history_fast) then fast_keys = 'hist:anal' else fast_keys = 'anal' end if - end select + !---------------------------------------------------------------------------------! + elseif (iadd_cohort_means /= 0) then + !---------------------------------------------------------------------------------! + ! Cohort averages not needed. Write to history only when we are writing ! + ! sub-daily history and saving site-level daily and/or monthly averages. ! + !---------------------------------------------------------------------------------! + if (history_fast) then + fast_keys = 'hist' + else + return + end if + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -30242,28 +30477,42 @@ subroutine filltab_patchtype_p41dmean(cpatch,igr,init,var_len,var_len_global,max + !------------------------------------------------------------------------------------! - ! Decide whether to write the daily means to the history file. ! + ! Decide whether to write the daily means to the history and/or the analysis ! + ! files. This depends on whether we are going to write daily means to analyses, or ! + ! whether we are writing monthly averages (in which case we may need to save daily ! + ! averages to history files). ! !------------------------------------------------------------------------------------! - select case (iadd_cohort_means) - case (0) - return - case (1) + if (btest(iadd_cohort_means,1)) then + !----- Cohort averages sought, decide whether or not to write to history. --------! if (history_dail) then dail_keys = 'hist:dail' else dail_keys = 'dail' end if - end select + !---------------------------------------------------------------------------------! + elseif (btest(iadd_cohort_means,0)) then + !---------------------------------------------------------------------------------! + ! Cohort averages not needed. Write to history only when we are writing ! + ! sub-monthly history and saving site-level monthly averages. ! + !---------------------------------------------------------------------------------! + if (history_dail) then + dail_keys = 'hist' + else + return + end if + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! - - - - !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! ! This part should have only 1-D vectors, with dimension ncohorts. Notice ! @@ -31063,28 +31312,31 @@ subroutine filltab_patchtype_p41mmean(cpatch,igr,init,var_len,var_len_global,max + + !------------------------------------------------------------------------------------! - ! Decide whether to write the monthly means to the history file. ! + ! Decide whether to write the monthly mean to the history and/or the analysis ! + ! files. ! !------------------------------------------------------------------------------------! - select case (iadd_cohort_means) - case (0) - return - case (1) + if (btest(iadd_cohort_means,0)) then + !----- Cohort averages sought, decide whether or not to write to history. --------! if (history_eorq) then eorq_keys = 'hist:mont:dcyc' else eorq_keys = 'mont:dcyc' end if - end select + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! - - - !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! ! This part should have only 1-D vectors, with dimension ncohorts. Notice ! @@ -32116,19 +32368,25 @@ subroutine filltab_patchtype_m41(cpatch,igr,init,var_len,var_len_global,max_ptrs + + !------------------------------------------------------------------------------------! - ! Decide whether to write the mean diel to the history file. ! + ! Decide whether to write the monthly mean diel to the history and/or the ! + ! analysis files. ! !------------------------------------------------------------------------------------! - select case (iadd_cohort_means) - case (0) - return - case (1) + if (btest(iadd_cohort_means,0)) then + !----- Cohort averages sought, decide whether or not to write to history. --------! if (history_eorq) then eorq_keys = 'hist:dcyc' else eorq_keys = 'dcyc' end if - end select + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -32935,9 +33193,13 @@ subroutine filltab_patchtype_p42(cpatch,igr,init,var_len,var_len_global,max_ptrs character(len=str_len) :: fast_keys character(len=str_len) :: dail_keys character(len=str_len) :: eorq_keys + logical :: add_fast + logical :: add_dail + logical :: add_eorq !------------------------------------------------------------------------------------! + !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! ! This part should have only 2-D vectors with dimensions ncohorts and nzg. ! @@ -32955,61 +33217,169 @@ subroutine filltab_patchtype_p42(cpatch,igr,init,var_len,var_len_global,max_ptrs end if !------------------------------------------------------------------------------------! + + + + + !------------------------------------------------------------------------------------! - ! Decide whether to write the fast, daily, and monthly means to the history. ! + ! Decide whether to write the fast, daily, and monthly means to the history ! + ! and/or analysis files. ! !------------------------------------------------------------------------------------! - select case (iadd_patch_means) + select case (iadd_cohort_means) case (0) + !----- Nothing to be written. ----------------------------------------------------! return - case (1) - if (history_fast) then - fast_keys = 'hist:anal' + !---------------------------------------------------------------------------------! + case default + !---------------------------------------------------------------------------------! + ! Turn on all the averages. We then disable those that are not needed. ! + !---------------------------------------------------------------------------------! + add_fast = .true. + add_dail = .true. + add_eorq = .true. + !---------------------------------------------------------------------------------! + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the sub-daily means to the history and/or the ! + ! analysis files. This depends on whether we are going to write sub-daily means ! + ! to analyses, or whether we are writing daily/monthly averages (in which case we ! + ! may need to save sub-daily averages to history files). ! + !---------------------------------------------------------------------------------! + if (btest(iadd_cohort_means,2)) then + !----- Cohort averages sought, decide whether or not to write to history. -----! + if (history_fast) then + fast_keys = 'hist:anal' + else + fast_keys = 'anal' + end if + !------------------------------------------------------------------------------! + elseif (history_fast) then + !------------------------------------------------------------------------------! + ! Cohort averages not needed, but we must add them to history because we ! + ! are saving cohort-level daily and/or monthly averages. ! + !------------------------------------------------------------------------------! + fast_keys = 'hist' + !------------------------------------------------------------------------------! else - fast_keys = 'anal' + !----- No need to include sub-daily averages. ---------------------------------! + add_fast = .false. + !------------------------------------------------------------------------------! end if - if (history_dail) then - dail_keys = 'hist:dail' + !---------------------------------------------------------------------------------! + + + + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the daily means to the history and/or the analysis ! + ! files. This depends on whether we are going to write daily means to analyses, ! + ! or whether we are writing monthly averages (in which case we may need to save ! + ! daily averages to history files). ! + !---------------------------------------------------------------------------------! + if (btest(iadd_cohort_means,1)) then + !----- Cohort averages sought, decide whether or not to write to history. -----! + if (history_dail) then + dail_keys = 'hist:dail' + else + dail_keys = 'dail' + end if + !------------------------------------------------------------------------------! + elseif (btest(iadd_cohort_means,0) .and. history_dail) then + !------------------------------------------------------------------------------! + ! Cohort averages not needed, but we must add them to history because we ! + ! are saving cohort-level monthly averages. ! + !------------------------------------------------------------------------------! + dail_keys = 'hist' + !------------------------------------------------------------------------------! else - dail_keys = 'dail' + !----- No need to go include daily variables. ---------------------------------! + add_dail = .false. + !------------------------------------------------------------------------------! end if - if (history_eorq) then - eorq_keys = 'hist:mont:dcyc' + !---------------------------------------------------------------------------------! + + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the mean diel to the history and/or the analysis ! + ! files. ! + !---------------------------------------------------------------------------------! + if (btest(iadd_cohort_means,0)) then + !----- Cohort averages sought, decide whether or not to write to history. -----! + if (history_eorq) then + eorq_keys = 'hist:mont:dcyc' + else + eorq_keys = 'mont:dcyc' + end if + !------------------------------------------------------------------------------! else - eorq_keys = 'mont:dcyc' + !----- No need to go include daily variables. ---------------------------------! + add_eorq = .false. + !------------------------------------------------------------------------------! end if + !---------------------------------------------------------------------------------! end select !------------------------------------------------------------------------------------! - if (associated(cpatch%fmean_wflux_gw_layer )) then - nvar = nvar+1 - call vtable_edio_r(npts,cpatch%fmean_wflux_gw_layer & - ,nvar,igr,init,cpatch%coglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_WFLUX_GW_LAYER_CO :42:'//trim(fast_keys) ) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Water flux from ground to wood' & - ,'[ kg/s]','(nzg,icohort)' ) - end if - if (associated(cpatch%dmean_wflux_gw_layer )) then - nvar = nvar+1 - call vtable_edio_r(npts,cpatch%dmean_wflux_gw_layer & - ,nvar,igr,init,cpatch%coglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_WFLUX_GW_LAYER_CO :42:'//trim(dail_keys) ) - call metadata_edio(nvar,igr & - ,'Daily mean - Water flux from ground to wood' & - ,'[ kg/s]','(nzg,icohort)' ) + + !------------------------------------------------------------------------------------! + ! Fast averages block. ! + !------------------------------------------------------------------------------------! + if (add_fast) then + if (associated(cpatch%fmean_wflux_gw_layer )) then + nvar = nvar+1 + call vtable_edio_r(npts,cpatch%fmean_wflux_gw_layer & + ,nvar,igr,init,cpatch%coglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_WFLUX_GW_LAYER_CO :42:'//trim(fast_keys) ) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Water flux from ground to wood' & + ,'[ kg/s]','(nzg,icohort)' ) + end if end if - if (associated(cpatch%mmean_wflux_gw_layer )) then - nvar = nvar+1 - call vtable_edio_r(npts,cpatch%mmean_wflux_gw_layer & - ,nvar,igr,init,cpatch%coglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_WFLUX_GW_LAYER_CO :42:'//trim(eorq_keys) ) - call metadata_edio(nvar,igr & - ,'Monthly mean - Water flux from ground to wood' & - ,'[ kg/s]','(nzg,icohort)' ) + !------------------------------------------------------------------------------------! + + + + !------------------------------------------------------------------------------------! + ! Daily averages block. ! + !------------------------------------------------------------------------------------! + if (add_dail) then + if (associated(cpatch%dmean_wflux_gw_layer )) then + nvar = nvar+1 + call vtable_edio_r(npts,cpatch%dmean_wflux_gw_layer & + ,nvar,igr,init,cpatch%coglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_WFLUX_GW_LAYER_CO :42:'//trim(dail_keys) ) + call metadata_edio(nvar,igr & + ,'Daily mean - Water flux from ground to wood' & + ,'[ kg/s]','(nzg,icohort)' ) + end if end if !------------------------------------------------------------------------------------! + + + + !------------------------------------------------------------------------------------! + ! Monthly averages block. ! + !------------------------------------------------------------------------------------! + if (add_eorq) then + if (associated(cpatch%mmean_wflux_gw_layer )) then + nvar = nvar+1 + call vtable_edio_r(npts,cpatch%mmean_wflux_gw_layer & + ,nvar,igr,init,cpatch%coglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_WFLUX_GW_LAYER_CO :42:'//trim(eorq_keys) ) + call metadata_edio(nvar,igr & + ,'Monthly mean - Water flux from ground to wood' & + ,'[ kg/s]','(nzg,icohort)' ) + end if + end if !------------------------------------------------------------------------------------! return @@ -33069,19 +33439,24 @@ subroutine filltab_patchtype_p48(cpatch,igr,init,var_len,var_len_global,max_ptrs + !------------------------------------------------------------------------------------! - ! Decide whether to write the monthly means to the history file. ! + ! Decide whether to write the monthly mean to the history and/or the analysis ! + ! files. ! !------------------------------------------------------------------------------------! - select case (iadd_cohort_means) - case (0) - return - case (1) + if (btest(iadd_cohort_means,0)) then + !----- Cohort averages sought, decide whether or not to write to history. --------! if (history_eorq) then eorq_keys = 'hist:mont:dcyc' else eorq_keys = 'mont:dcyc' end if - end select + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! @@ -33215,6 +33590,9 @@ subroutine filltab_patchtype_p411(cpatch,igr,init,var_len,var_len_global,max_ptr character(len=str_len) :: fast_keys character(len=str_len) :: dail_keys character(len=str_len) :: eorq_keys + logical :: add_fast + logical :: add_dail + logical :: add_eorq !------------------------------------------------------------------------------------! @@ -33240,71 +33618,171 @@ subroutine filltab_patchtype_p411(cpatch,igr,init,var_len,var_len_global,max_ptr + + !------------------------------------------------------------------------------------! - ! Decide whether to write the monthly means to the history file. ! + ! Decide whether to write the fast, daily, and monthly means to the history ! + ! and/or analysis files. ! !------------------------------------------------------------------------------------! select case (iadd_cohort_means) case (0) + !----- Nothing to be written. ----------------------------------------------------! return - case (1) - if (history_fast) then - fast_keys = 'hist:anal' + !---------------------------------------------------------------------------------! + case default + !---------------------------------------------------------------------------------! + ! Turn on all the averages. We then disable those that are not needed. ! + !---------------------------------------------------------------------------------! + add_fast = .true. + add_dail = .true. + add_eorq = .true. + !---------------------------------------------------------------------------------! + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the sub-daily means to the history and/or the ! + ! analysis files. This depends on whether we are going to write sub-daily means ! + ! to analyses, or whether we are writing daily/monthly averages (in which case we ! + ! may need to save sub-daily averages to history files). ! + !---------------------------------------------------------------------------------! + if (btest(iadd_cohort_means,2)) then + !----- Cohort averages sought, decide whether or not to write to history. -----! + if (history_fast) then + fast_keys = 'hist:anal' + else + fast_keys = 'anal' + end if + !------------------------------------------------------------------------------! + elseif (history_fast) then + !------------------------------------------------------------------------------! + ! Cohort averages not needed, but we must add them to history because we ! + ! are saving cohort-level daily and/or monthly averages. ! + !------------------------------------------------------------------------------! + fast_keys = 'hist' + !------------------------------------------------------------------------------! else - fast_keys = 'anal' + !----- No need to include sub-daily averages. ---------------------------------! + add_fast = .false. + !------------------------------------------------------------------------------! end if - if (history_dail) then - dail_keys = 'hist:dail' + !---------------------------------------------------------------------------------! + + + + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the daily means to the history and/or the analysis ! + ! files. This depends on whether we are going to write daily means to analyses, ! + ! or whether we are writing monthly averages (in which case we may need to save ! + ! daily averages to history files). ! + !---------------------------------------------------------------------------------! + if (btest(iadd_cohort_means,1)) then + !----- Cohort averages sought, decide whether or not to write to history. -----! + if (history_dail) then + dail_keys = 'hist:dail' + else + dail_keys = 'dail' + end if + !------------------------------------------------------------------------------! + elseif (btest(iadd_cohort_means,0) .and. history_dail) then + !------------------------------------------------------------------------------! + ! Cohort averages not needed, but we must add them to history because we ! + ! are saving cohort-level monthly averages. ! + !------------------------------------------------------------------------------! + dail_keys = 'hist' + !------------------------------------------------------------------------------! else - dail_keys = 'dail' + !----- No need to go include daily variables. ---------------------------------! + add_dail = .false. + !------------------------------------------------------------------------------! end if - if (history_eorq) then - eorq_keys = 'hist:mont:dcyc' + !---------------------------------------------------------------------------------! + + + + !---------------------------------------------------------------------------------! + ! Decide whether to write the mean diel to the history and/or the analysis ! + ! files. ! + !---------------------------------------------------------------------------------! + if (btest(iadd_cohort_means,0)) then + !----- Cohort averages sought, decide whether or not to write to history. -----! + if (history_eorq) then + eorq_keys = 'hist:mont:dcyc' + else + eorq_keys = 'mont:dcyc' + end if + !------------------------------------------------------------------------------! else - eorq_keys = 'mont:dcyc' + !----- No need to go include daily variables. ---------------------------------! + add_eorq = .false. + !------------------------------------------------------------------------------! end if + !---------------------------------------------------------------------------------! end select !------------------------------------------------------------------------------------! + + !------------------------------------------------------------------------------------! - if (associated(cpatch%fmean_rad_profile)) then - nvar=nvar+1 - call vtable_edio_r(npts,cpatch%fmean_rad_profile & - ,nvar,igr,init,cpatch%coglob_id,var_len,var_len_global,max_ptrs & - ,'FMEAN_RAD_PROFILE_CO :411:'//trim(fast_keys)) - call metadata_edio(nvar,igr & - ,'Sub-daily mean - Radiation profile','[W/m2]' & - ,'(iradprof,icohort)') + ! Fast analysis block. ! + !------------------------------------------------------------------------------------! + if (add_fast) then + if (associated(cpatch%fmean_rad_profile)) then + nvar=nvar+1 + call vtable_edio_r(npts,cpatch%fmean_rad_profile & + ,nvar,igr,init,cpatch%coglob_id & + ,var_len,var_len_global,max_ptrs & + ,'FMEAN_RAD_PROFILE_CO :411:'//trim(fast_keys)) + call metadata_edio(nvar,igr & + ,'Sub-daily mean - Radiation profile','[W/m2]' & + ,'(iradprof,icohort)') + end if end if !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! + + !------------------------------------------------------------------------------------! - if (associated(cpatch%dmean_rad_profile)) then - nvar=nvar+1 - call vtable_edio_r(npts,cpatch%dmean_rad_profile & - ,nvar,igr,init,cpatch%coglob_id,var_len,var_len_global,max_ptrs & - ,'DMEAN_RAD_PROFILE_CO :411:'//trim(dail_keys)) - call metadata_edio(nvar,igr & - ,'Daily mean - Radiation profile','[W/m2]' & - ,'(iradprof,icohort)') + ! Daily analysis block. ! + !------------------------------------------------------------------------------------! + if (add_dail) then + if (associated(cpatch%dmean_rad_profile)) then + nvar=nvar+1 + call vtable_edio_r(npts,cpatch%dmean_rad_profile & + ,nvar,igr,init,cpatch%coglob_id & + ,var_len,var_len_global,max_ptrs & + ,'DMEAN_RAD_PROFILE_CO :411:'//trim(dail_keys)) + call metadata_edio(nvar,igr & + ,'Daily mean - Radiation profile','[W/m2]' & + ,'(iradprof,icohort)') + end if end if !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! + + !------------------------------------------------------------------------------------! - if (associated(cpatch%mmean_rad_profile)) then - nvar=nvar+1 - call vtable_edio_r(npts,cpatch%mmean_rad_profile & - ,nvar,igr,init,cpatch%coglob_id,var_len,var_len_global,max_ptrs & - ,'MMEAN_RAD_PROFILE_CO :411:'//trim(eorq_keys)) - call metadata_edio(nvar,igr & - ,'Monthly mean - Radiation profile','[W/m2]' & - ,'(iradprof,icohort)') + ! Monthly analysis block. ! + !------------------------------------------------------------------------------------! + if (add_eorq) then + if (associated(cpatch%mmean_rad_profile)) then + nvar=nvar+1 + call vtable_edio_r(npts,cpatch%mmean_rad_profile & + ,nvar,igr,init,cpatch%coglob_id & + ,var_len,var_len_global,max_ptrs & + ,'MMEAN_RAD_PROFILE_CO :411:'//trim(eorq_keys)) + call metadata_edio(nvar,igr & + ,'Monthly mean - Radiation profile','[W/m2]' & + ,'(iradprof,icohort)') + end if end if !------------------------------------------------------------------------------------! !------------------------------------------------------------------------------------! @@ -33348,19 +33826,24 @@ subroutine filltab_patchtype_m411(cpatch,igr,init,var_len,var_len_global,max_ptr + !------------------------------------------------------------------------------------! - ! Decide whether to write the monthly means to the history file. ! + ! Decide whether to write the monthly mean to the history and/or the analysis ! + ! files. ! !------------------------------------------------------------------------------------! - select case (iadd_cohort_means) - case (0) - return - case (1) + if (btest(iadd_cohort_means,0)) then + !----- Cohort averages sought, decide whether or not to write to history. --------! if (history_eorq) then eorq_keys = 'hist:dcyc' else eorq_keys = 'dcyc' end if - end select + !---------------------------------------------------------------------------------! + else + !----- No need to write anything. ------------------------------------------------! + return + !---------------------------------------------------------------------------------! + end if !------------------------------------------------------------------------------------! diff --git a/diff_version.sh b/diff_version.sh index 0f8afc588..77a083c15 100755 --- a/diff_version.sh +++ b/diff_version.sh @@ -24,8 +24,8 @@ subdirs="ED BRAMS Ramspost R-utils" #------ Editor to use (I've only tested with nedit, use others at your own risk). ---------# editor="nedit" #------ Two paths with EDBRAMS (full path). -----------------------------------------------# -ours="${HOME}/MainLine/EDBRAMS" -theirs="${HOME}/EDBRAMS" +ours="${HOME}/EDBRAMS" +theirs="${HOME}/MainLine/EDBRAMS" ournew=true #------------------------------------------------------------------------------------------#