From f0f00f793b358fc8e5856faf7c3d6c15367510eb Mon Sep 17 00:00:00 2001 From: ashleymedin <ashley.vanbeusekom@gmail.com> Date: Fri, 12 May 2023 22:10:52 +0900 Subject: [PATCH] trying to rename things so makes more sense what is changed --- actorsChanges.txt | 14 +- .../hru_actor_subroutine_wrappers.hpp | 4 +- .../{read_attribute.f90 => read_attrb.f90} | 14 +- .../{read_forcing.f90 => read_force.f90} | 2 +- ...itcond.f90 => read_icondFromStructure.f90} | 10 +- .../fortran_code/read_param.f90 | 2 +- .../actors/hru_actor/cpp_code/hru_actor.cpp | 4 +- .../{init_hru_actor.f90 => hru_init.f90} | 0 .../{model_run.f90 => hru_modelRun.f90} | 4 +- ...utputStrucWrite.f90 => hru_modelwrite.f90} | 12 +- .../{restart.f90 => hru_restart.f90} | 8 +- .../{setup_hru_sundials.f90 => hru_setup.f90} | 2 +- .../fortran_code/hru_writeOutput.f90 | 8 +- .../hru_actor/fortran_code/setup_hru.f90 | 511 ------------------ utils/extra_scripts/makefile-container | 6 +- 15 files changed, 51 insertions(+), 550 deletions(-) rename build/source/actors/file_access_actor/fortran_code/{read_attribute.f90 => read_attrb.f90} (97%) rename build/source/actors/file_access_actor/fortran_code/{read_forcing.f90 => read_force.f90} (99%) rename build/source/actors/file_access_actor/fortran_code/{read_initcond.f90 => read_icondFromStructure.f90} (97%) rename build/source/actors/hru_actor/fortran_code/{init_hru_actor.f90 => hru_init.f90} (100%) rename build/source/actors/hru_actor/fortran_code/{model_run.f90 => hru_modelRun.f90} (99%) rename build/source/actors/hru_actor/fortran_code/{outputStrucWrite.f90 => hru_modelwrite.f90} (99%) rename build/source/actors/hru_actor/fortran_code/{restart.f90 => hru_restart.f90} (98%) rename build/source/actors/hru_actor/fortran_code/{setup_hru_sundials.f90 => hru_setup.f90} (99%) delete mode 100644 build/source/actors/hru_actor/fortran_code/setup_hru.f90 diff --git a/actorsChanges.txt b/actorsChanges.txt index 2772fe0..24fb4fb 100644 --- a/actorsChanges.txt +++ b/actorsChanges.txt @@ -28,11 +28,23 @@ can remove sundials folder shouldn't need with SUNDIALS_ACTIVE /derivforce.f90 -- remove with ACTORS_ACTIVE tmZoneOffsetFracDay needs to be variable not global /ffile_info.f90 -- very different, call this ffile_infoActors? /mDecisions.f90 -- remove shouldn't need the non-sundials version -/read_dimension.-- part of read_attrb, - very different, actors doesn't use rest of read_attribute which was cut, maybe better, but then this and the other changes in it should be applied to all versions! and I don't see it called anywhere in Actors ... removed BUT SHOULD IT JUST REPLACE THE SUMMA read_dimension? +/read_dimension.-- remove, part of read_attrb, - some deallocation changes, use this in all (not actually used in actors, ??) + - also Actors assumes don't have aspect variable .. why? /read_pinit.f90 -- remove /vegPhenlgy.f90 -- remove with ACTORS_ACTIVE needs fracJulDay, yearLength +SUMMA_FILEACCESS_INTERFACE = \ + output_structure.f90 \ + cppwrap_fileAccess.f90 \ + read_attrb.f90 \ + read_force.f90 \ + read_param.f90 \ + read_icondFromStructure.f90 \ +ARE THESE ALL SORT OF REPEATS?? DO WE EVEN USE ALL OF THEM? specifically read_icondFromStructure ... what is that ... do we call its +Can we give them the same names as the regular summa files if they are repeats, so we know to change them?? + + changed calls in run_oneHRU so can use (modded) currently in actors /derivforce.f90 /coupled_em.f90 /vegPhenlgy.f90 as is diff --git a/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp b/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp index 7333c36..df1dab9 100644 --- a/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp +++ b/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp @@ -32,8 +32,8 @@ extern "C" { double* upArea, int* err); - // Setup Restart File if this option has been chosen - void Restart( + // Setup summa_readRestart File if this option has been chosen + void summa_readRestart( int* indxGRU, int* indxHRU, // primary data structures (variable length vectors) void* indxStruct, void* mparStruct, void* progStruct, void* diagStruct, void* fluxStruct, diff --git a/build/source/actors/file_access_actor/fortran_code/read_attribute.f90 b/build/source/actors/file_access_actor/fortran_code/read_attrb.f90 similarity index 97% rename from build/source/actors/file_access_actor/fortran_code/read_attribute.f90 rename to build/source/actors/file_access_actor/fortran_code/read_attrb.f90 index 2351c3a..7c58fab 100644 --- a/build/source/actors/file_access_actor/fortran_code/read_attribute.f90 +++ b/build/source/actors/file_access_actor/fortran_code/read_attrb.f90 @@ -1,4 +1,4 @@ -module read_attribute_module +module read_attrb_module USE, intrinsic :: iso_c_binding USE nrtype @@ -38,7 +38,7 @@ subroutine allocateAttributeStructures(index_gru, index_hru, & ! indexes into gr call c_f_pointer(handle_type_struct, type_struct) call c_f_pointer(handle_id_struct, id_struct) ! Start subroutine - err=0; message="read_attribute.f90 - allocateAttributeStructures" + err=0; message="read_attrb.f90 - allocateAttributeStructures" nSnow = gru_struc(index_gru)%hruInfo(index_hru)%nSnow nSoil = gru_struc(index_gru)%hruInfo(index_hru)%nSoil @@ -65,7 +65,7 @@ subroutine openAttributeFile(attr_ncid, err) bind(C, name="openAttributeFile") character(len=256) :: message ! error message character(len=256) :: attrFile ! attributes file name - err=0; message="read_attribute.f90 - openAttributesFile" + err=0; message="read_attrb.f90 - openAttributesFile" attrFile = trim(SETTINGS_PATH)//trim(LOCAL_ATTRIBUTES) call nc_file_open(trim(attrFile),nf90_noWrite,attr_ncid,err,message) @@ -87,7 +87,7 @@ subroutine getNumVarAttr(attr_ncid, num_var, err) bind(C, name="getNumVarAttr") ! local variables character(len=256) :: message ! error message - err=0; message="read_attribute.f90 - getNumVar" + err=0; message="read_attrb.f90 - getNumVar" ! get number of variables total in netcdf file err = nf90_inquire(attr_ncid,nvariables=num_var) call netcdf_err(err,message) @@ -105,7 +105,7 @@ subroutine closeAttributeFile(attr_ncid, err) bind(C, name="closeAttributeFile") integer(c_int),intent(out) :: err ! local variables character(len=256) :: message - err=0; message="read_attribute.f90 - closeAttributeFile" + err=0; message="read_attrb.f90 - closeAttributeFile" call nc_file_close(attr_ncid,err,message) if (err/=0)then @@ -177,7 +177,7 @@ subroutine readAttributeFromNetCDF(ncid, index_gru, index_hru, num_var, & call c_f_pointer(handle_type_struct, type_struct) call c_f_pointer(handle_id_struct, id_struct) - err=0; message="read_attribute_file_access_actor - read_attribute.f90" + err=0; message="read_attrb_file_access_actor - read_attrb.f90" attr_file= trim(SETTINGS_PATH)//trim(LOCAL_ATTRIBUTES) @@ -353,4 +353,4 @@ subroutine readAttributeFromNetCDF(ncid, index_gru, index_hru, num_var, & deallocate(checkId) deallocate(checkAttr) end subroutine readAttributeFromNetCDF -end module read_attribute_module +end module read_attrb_module diff --git a/build/source/actors/file_access_actor/fortran_code/read_forcing.f90 b/build/source/actors/file_access_actor/fortran_code/read_force.f90 similarity index 99% rename from build/source/actors/file_access_actor/fortran_code/read_forcing.f90 rename to build/source/actors/file_access_actor/fortran_code/read_force.f90 index 3ed7f31..751dc8f 100644 --- a/build/source/actors/file_access_actor/fortran_code/read_forcing.f90 +++ b/build/source/actors/file_access_actor/fortran_code/read_force.f90 @@ -60,7 +60,7 @@ subroutine read_forcingFile(handle_forcFileInfo, iFile, stepsInFile, startGRU, n call c_f_pointer(handle_forcFileInfo, forcFileInfo) ! Start Procedure here - err=0; message="read_forcing.f90 - read_forcingFile/" + err=0; message="read_force.f90 - read_forcingFile/" nFiles=size(forcFileInfo%ffile_list(:)) diff --git a/build/source/actors/file_access_actor/fortran_code/read_initcond.f90 b/build/source/actors/file_access_actor/fortran_code/read_icondFromStructure.f90 similarity index 97% rename from build/source/actors/file_access_actor/fortran_code/read_initcond.f90 rename to build/source/actors/file_access_actor/fortran_code/read_icondFromStructure.f90 index fefff72..6eabadd 100644 --- a/build/source/actors/file_access_actor/fortran_code/read_initcond.f90 +++ b/build/source/actors/file_access_actor/fortran_code/read_icondFromStructure.f90 @@ -1,4 +1,4 @@ -module read_initcond_module +module read_icondFromStructure_module USE, intrinsic :: iso_c_binding USE nrtype @@ -59,7 +59,7 @@ subroutine closeInitCondFile(init_cond_ncid,err) bind(C, name="closeInitCondFile ! local variables character(len=256) :: message ! -------------------------------------------------------------------------------------------------------- - err=0; message="read_initcond.f90 - closeInitCondFile/" + err=0; message="read_icondFromStructure.f90 - closeInitCondFile/" call nc_file_close(init_cond_ncid,err,message) if (err/=0) then @@ -113,7 +113,7 @@ subroutine readInitCond_prog(init_cond_ncid, start_gru, num_gru, err) bind(C, na character(len=32),parameter :: ifcTotoDimName='ifcToto' ! dimension name for layered varaiables ! -------------------------------------------------------------------------------------------------------- - err=0; message="read_initcond.f90 - readInitCond_prog" + err=0; message="read_icondFromStructure.f90 - readInitCond_prog" ! get number of HRUs in file err = nf90_inq_dimid(init_cond_ncid,"hru",dimID); @@ -216,7 +216,7 @@ subroutine readInitCond_bvar(init_cond_ncid, start_gru, num_gru, err) bind(C, na character(len=32),parameter :: tdhDimName ='tdh' ! dimension name for time-delay basin variables ! -------------------------------------------------------------------------------------------------------- - err = 0; message="read_initcond.f90 - readInitCond_bvar/" + err = 0; message="read_icondFromStructure.f90 - readInitCond_bvar/" if(restartFileType/=singleHRU)then ! get dimension of time delay histogram (TDH) from initial conditions file err = nf90_inq_dimid(init_cond_ncid,"tdh",dimID); @@ -277,4 +277,4 @@ end subroutine readInitCond_bvar -end module read_initcond_module \ No newline at end of file +end module read_icondFromStructure_module \ No newline at end of file diff --git a/build/source/actors/file_access_actor/fortran_code/read_param.f90 b/build/source/actors/file_access_actor/fortran_code/read_param.f90 index 3c7c38e..e8d8c67 100644 --- a/build/source/actors/file_access_actor/fortran_code/read_param.f90 +++ b/build/source/actors/file_access_actor/fortran_code/read_param.f90 @@ -43,7 +43,7 @@ subroutine allocateParamStructures(index_gru, index_hru, handle_dpar_struct, & call c_f_pointer(handle_mpar_struct, mpar_struct) call c_f_pointer(handle_bpar_struct, bpar_struct) ! start of subroutine - err=0; message="read_attribute.f90 - allocateAttributeStructures" + err=0; message="read_attrb.f90 - allocateAttributeStructures" nSnow = gru_struc(index_gru)%hruInfo(index_hru)%nSnow nSoil = gru_struc(index_gru)%hruInfo(index_hru)%nSoil diff --git a/build/source/actors/hru_actor/cpp_code/hru_actor.cpp b/build/source/actors/hru_actor/cpp_code/hru_actor.cpp index 89108d4..306d13a 100644 --- a/build/source/actors/hru_actor/cpp_code/hru_actor.cpp +++ b/build/source/actors/hru_actor/cpp_code/hru_actor.cpp @@ -226,7 +226,7 @@ void Initialize_HRU(stateful_actor<hru_state>* self) { return; } - Restart(&self->state.indxGRU, + summa_readRestart(&self->state.indxGRU, &self->state.indxHRU, self->state.handle_indxStruct, self->state.handle_mparStruct, @@ -236,7 +236,7 @@ void Initialize_HRU(stateful_actor<hru_state>* self) { self->state.handle_bvarStruct, &self->state.dt_init, &self->state.err); if (self->state.err != 0) { - aout(self) << "Error: HRU_Actor - Restart - HRU = " << self->state.indxHRU << + aout(self) << "Error: HRU_Actor - summa_readRestart - HRU = " << self->state.indxHRU << " - indxGRU = " << self->state.indxGRU << " - refGRU = " << self->state.refGRU << std::endl; self->quit(); return; diff --git a/build/source/actors/hru_actor/fortran_code/init_hru_actor.f90 b/build/source/actors/hru_actor/fortran_code/hru_init.f90 similarity index 100% rename from build/source/actors/hru_actor/fortran_code/init_hru_actor.f90 rename to build/source/actors/hru_actor/fortran_code/hru_init.f90 diff --git a/build/source/actors/hru_actor/fortran_code/model_run.f90 b/build/source/actors/hru_actor/fortran_code/hru_modelRun.f90 similarity index 99% rename from build/source/actors/hru_actor/fortran_code/model_run.f90 rename to build/source/actors/hru_actor/fortran_code/hru_modelRun.f90 index b0814e5..5268b47 100644 --- a/build/source/actors/hru_actor/fortran_code/model_run.f90 +++ b/build/source/actors/hru_actor/fortran_code/hru_modelRun.f90 @@ -18,7 +18,7 @@ ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. -module model_run +module summa_modelRun ! calls the model physics USE,intrinsic :: iso_c_binding @@ -427,4 +427,4 @@ subroutine runPhysics(& end subroutine runPhysics -end module model_run +end module summa_modelRun diff --git a/build/source/actors/hru_actor/fortran_code/outputStrucWrite.f90 b/build/source/actors/hru_actor/fortran_code/hru_modelwrite.f90 similarity index 99% rename from build/source/actors/hru_actor/fortran_code/outputStrucWrite.f90 rename to build/source/actors/hru_actor/fortran_code/hru_modelwrite.f90 index 37b4b74..a71f284 100755 --- a/build/source/actors/hru_actor/fortran_code/outputStrucWrite.f90 +++ b/build/source/actors/hru_actor/fortran_code/hru_modelwrite.f90 @@ -19,7 +19,7 @@ ! along with this program. If not, see <http://www.gnu.org/licenses/>. ! Module contains subroutines for writing to the global output strucutre -module outputStrucWrite_module +module hru_modelwrite_module ! NetCDF types USE netcdf @@ -100,7 +100,7 @@ subroutine writeParm(indxGRU,indxHRU,ispatial,struct,meta,structName,err,message integer(i4b) :: iVar ! loop through variables ! initialize error control - err=0;message="outputStrucWrite.f90-writeParm/" + err=0;message="hru_modelwrite.f90-writeParm/" ! loop through local column model parameters do iVar = 1,size(meta) @@ -194,7 +194,7 @@ subroutine writeData(indxGRU,indxHRU,iStep,structName,finalizeStats, & integer(i4b),parameter :: ixInteger=1001 ! named variable for integer integer(i4b),parameter :: ixReal=1002 ! named variable for real ! initialize error control - err=0;message="outputStrucWrite.f90-writeData/" + err=0;message="hru_modelwrite.f90-writeData/" ! loop through output frequencies do iFreq=1,maxvarFreq @@ -338,7 +338,7 @@ subroutine writeBasin(indxGRU,indxHRU,iStep,finalizeStats,& integer(i4b) :: iStat ! statistics index integer(i4b) :: iFreq ! frequency index ! initialize error control - err=0;message="outputStrucWrite.f90-writeBasin/" + err=0;message="hru_modelwrite.f90-writeBasin/" ! loop through output frequencies do iFreq=1,maxvarFreq @@ -402,7 +402,7 @@ subroutine writeTime(indxGRU,indxHRU,iStep,finalizeStats,meta,dat,err,message) integer(i4b) :: iVar ! variable index integer(i4b) :: iFreq ! frequency index ! initialize error control - err=0;message="outputStrucWrite.f90-writeTime/" + err=0;message="hru_modelwrite.f90-writeTime/" ! loop through output frequencies do iFreq=1,maxvarFreq @@ -699,4 +699,4 @@ subroutine writeRestart(filename, & ! intent(in): name of restart file end subroutine writeRestart -end module outputStrucWrite_module +end module hru_modelwrite_module diff --git a/build/source/actors/hru_actor/fortran_code/restart.f90 b/build/source/actors/hru_actor/fortran_code/hru_restart.f90 similarity index 98% rename from build/source/actors/hru_actor/fortran_code/restart.f90 rename to build/source/actors/hru_actor/fortran_code/hru_restart.f90 index 44324a5..c7ea337 100644 --- a/build/source/actors/hru_actor/fortran_code/restart.f90 +++ b/build/source/actors/hru_actor/fortran_code/hru_restart.f90 @@ -45,11 +45,11 @@ USE var_lookup,only:iLookDECISIONS ! look-up values for ! safety: set private unless specified otherwise implicit none private -public::Restart +public::summa_readRestart contains ! read restart data and reset the model state -subroutine Restart(& +subroutine summa_readRestart(& indxGRU, & ! index of GRU in gru_struc indxHRU, & ! index of HRU in gru_struc ! primary data structures (variable length vectors) @@ -61,7 +61,7 @@ subroutine Restart(& ! basin-average structures handle_bvarStruct, & ! x%var(:)%dat -- basin-average variables dt_init, & ! used to initialize the length of the sub-step for each HRU - err) bind(C,name='Restart') + err) bind(C,name='summa_readRestart') ! --------------------------------------------------------------------------------------- ! * desired modules ! --------------------------------------------------------------------------------------- @@ -240,7 +240,7 @@ subroutine Restart(& ! *** finalize ! ***************************************************************************** -end subroutine Restart +end subroutine summa_readRestart end module summa_restart diff --git a/build/source/actors/hru_actor/fortran_code/setup_hru_sundials.f90 b/build/source/actors/hru_actor/fortran_code/hru_setup.f90 similarity index 99% rename from build/source/actors/hru_actor/fortran_code/setup_hru_sundials.f90 rename to build/source/actors/hru_actor/fortran_code/hru_setup.f90 index c6443c5..60e5fc7 100644 --- a/build/source/actors/hru_actor/fortran_code/setup_hru_sundials.f90 +++ b/build/source/actors/hru_actor/fortran_code/hru_setup.f90 @@ -93,7 +93,7 @@ subroutine setupHRUParam(& use time_utils_module,only:elapsedSec ! calculate the elapsed time USE mDecisions_module,only:mDecisions ! module to read model decisions USE ffile_info_module,only:ffile_info ! module to read information on forcing datafile - ! USE read_attribute_module,only:read_attribute ! module to read local attributes + ! USE read_attrb_module,only:read_attrb ! module to read local attributes USE paramCheck_module,only:paramCheck ! module to check consistency of model parameters USE pOverwrite_module,only:pOverwrite ! module to overwrite default parameter values with info from the Noah tables USE ConvE2Temp_module,only:E2T_lookup ! module to calculate a look-up table for the temperature-enthalpy conversion diff --git a/build/source/actors/hru_actor/fortran_code/hru_writeOutput.f90 b/build/source/actors/hru_actor/fortran_code/hru_writeOutput.f90 index a32b1f2..3fd07da 100644 --- a/build/source/actors/hru_actor/fortran_code/hru_writeOutput.f90 +++ b/build/source/actors/hru_actor/fortran_code/hru_writeOutput.f90 @@ -146,10 +146,10 @@ subroutine writeHRUToOutputStructure(& USE globalData,only:forc_meta,attr_meta,type_meta ! metaData structures USE output_stats,only:calcStats ! module for compiling output statistics - USE outputStrucWrite_module,only:writeData,writeBasin ! module to write model output - USE outputStrucWrite_module,only:writeTime ! module to write model time - USE outputStrucWrite_module,only:writeRestart ! module to write model Restart - USE outputStrucWrite_module,only:writeParm ! module to write model parameters + USE hru_modelwrite_module,only:writeData,writeBasin ! module to write model output + USE hru_modelwrite_module,only:writeTime ! module to write model time + USE hru_modelwrite_module,only:writeRestart ! module to write model summa_readRestart + USE hru_modelwrite_module,only:writeParm ! module to write model parameters USE time_utils_module,only:elapsedSec ! calculate the elapsed time USE globalData,only:elapsedWrite ! elapsed time to write data USE output_structure_module,only:outputStructure diff --git a/build/source/actors/hru_actor/fortran_code/setup_hru.f90 b/build/source/actors/hru_actor/fortran_code/setup_hru.f90 deleted file mode 100644 index a1ff54e..0000000 --- a/build/source/actors/hru_actor/fortran_code/setup_hru.f90 +++ /dev/null @@ -1,511 +0,0 @@ -! SUMMA - Structure for Unifying Multiple Modeling Alternatives -! Copyright (C) 2014-2020 NCAR/RAL; University of Saskatchewan; University of Washington -! -! This file is part of SUMMA -! -! For more information see: http://www.ral.ucar.edu/projects/summa -! -! This program is free software: you can redistribute it and/or modify -! it under the terms of the GNU General Public License as published by -! the Free Software Foundation, either version 3 of the License, or -! (at your option) any later version. -! -! This program is distributed in the hope that it will be useful, -! but WITHOUT ANY WARRANTY; without even the implied warranty of -! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -! GNU General Public License for more details. -! -! You should have received a copy of the GNU General Public License -! along with this program. If not, see <http://www.gnu.org/licenses/>. - -module SummaActors_setup -USE,intrinsic :: iso_c_binding - -! initializes parameter data structures (e.g. vegetation and soil parameters). - -USE data_types,only:& - ! no spatial dimension - var_i, & ! x%var(:) (i4b) - var_i8, & ! x%var(:) (i8b) - var_d, & ! x%var(:) (dp) - var_ilength, & ! x%var(:)%dat (i4b) - var_dlength, & ! x%var(:)%dat (dp) - zLookup - -! access missing values -USE globalData,only:integerMissing ! missing integer -USE globalData,only:realMissing ! missing double precision number - -! named variables -USE var_lookup,only:iLookATTR ! look-up values for local attributes -USE var_lookup,only:iLookTYPE ! look-up values for classification of veg, soils etc. -USE var_lookup,only:iLookPARAM ! look-up values for local column model parameters -USE var_lookup,only:iLookID ! look-up values for local column model parameters -USE var_lookup,only:iLookBVAR ! look-up values for basin-average model variables -USE var_lookup,only:iLookDECISIONS ! look-up values for model decisions -USE globalData,only:urbanVegCategory ! vegetation category for urban areas - -! metadata structures -USE globalData,only:mpar_meta,bpar_meta ! parameter metadata structures - -! named variables to define the decisions for snow layers -USE mDecisions_module,only:& - sameRulesAllLayers, & ! SNTHERM option: same combination/sub-dividion rules applied to all layers - rulesDependLayerIndex ! CLM option: combination/sub-dividion rules depend on layer index - -! named variables to define LAI decisions -USE mDecisions_module,only:& - monthlyTable,& ! LAI/SAI taken directly from a monthly table for different vegetation classes - specified ! LAI/SAI computed from green vegetation fraction and winterSAI and summerLAI parameters - -! safety: set private unless specified otherwise -implicit none -private -public::setupHRUParam -public::SOIL_VEG_GEN_PARM -contains - -! initializes parameter data structures (e.g. vegetation and soil parameters). -subroutine setupHRUParam(& - indxGRU, & ! ID of hru - indxHRU, & ! Index of the parent GRU of the HRU - ! primary data structures (scalars) - handle_attrStruct, & ! local attributes for each HRU - handle_typeStruct, & ! local classification of soil veg etc. for each HRU - handle_idStruct, & ! local classification of soil veg etc. for each HRU - ! primary data structures (variable length vectors) - handle_mparStruct, & ! model parameters - handle_bparStruct, & ! basin-average parameters - handle_bvarStruct, & ! basin-average variables - handle_dparStruct, & ! default model parameters - handle_lookupStruct, & ! lookup tables - ! local HRU data - handle_startTime, & ! start time for the model simulation - handle_oldTime, & ! time for the previous model time step - ! miscellaneous variables - upArea, & ! area upslope of each HRU, - err) bind(C, name='setupHRUParam') - ! --------------------------------------------------------------------------------------- - ! * desired modules - ! --------------------------------------------------------------------------------------- - USE nrtype ! variable types, etc. - ! subroutines and functions - use time_utils_module,only:elapsedSec ! calculate the elapsed time - USE mDecisions_module,only:mDecisions ! module to read model decisions - USE ffile_info_module,only:ffile_info ! module to read information on forcing datafile - ! USE read_attribute_module,only:read_attribute ! module to read local attributes - USE paramCheck_module,only:paramCheck ! module to check consistency of model parameters - USE pOverwrite_module,only:pOverwrite ! module to overwrite default parameter values with info from the Noah tables - USE ConvE2Temp_module,only:E2T_lookup ! module to calculate a look-up table for the temperature-enthalpy conversion - USE t2enthalpy_module,only:T2E_lookup ! module to calculate a look-up table for the temperature-enthalpy conversion - USE var_derive_module,only:fracFuture ! module to calculate the fraction of runoff in future time steps (time delay histogram) - USE module_sf_noahmplsm,only:read_mp_veg_parameters ! module to read NOAH vegetation tables - ! global data structures - USE globalData,only:gru_struc ! gru-hru mapping structures - USE globalData,only:localParFallback ! local column default parameters - USE globalData,only:model_decisions ! model decision structure - USE globalData,only:greenVegFrac_monthly ! fraction of green vegetation in each month (0-1) - ! output constraints - USE globalData,only:maxLayers ! maximum number of layers - USE globalData,only:maxSnowLayers ! maximum number of snow layers - ! timing variables - USE globalData,only:startSetup,endSetup ! date/time for the start and end of the parameter setup - USE globalData,only:elapsedSetup ! elapsed time for the parameter setup - ! Noah-MP parameters - USE NOAHMP_VEG_PARAMETERS,only:SAIM,LAIM ! 2-d tables for stem area index and leaf area index (vegType,month) - USE NOAHMP_VEG_PARAMETERS,only:HVT,HVB ! height at the top and bottom of vegetation (vegType) - - ! --------------------------------------------------------------------------------------- - ! * variables - ! --------------------------------------------------------------------------------------- - implicit none - ! dummy variables - ! calling variables - integer(c_int),intent(in) :: indxGRU ! Index of the parent GRU of the HRU - integer(c_int),intent(in) :: indxHRU ! ID to locate correct HRU from netcdf file - type(c_ptr), intent(in), value :: handle_attrStruct ! local attributes for each HRU - type(c_ptr), intent(in), value :: handle_typeStruct ! local classification of soil veg etc. for each HRU - type(c_ptr), intent(in), value :: handle_idStruct ! - type(c_ptr), intent(in), value :: handle_mparStruct ! model parameters - type(c_ptr), intent(in), value :: handle_bparStruct ! basin-average parameters - type(c_ptr), intent(in), value :: handle_bvarStruct ! basin-average variables - type(c_ptr), intent(in), value :: handle_dparStruct ! default model parameters - type(c_ptr), intent(in), value :: handle_lookupStruct ! start time for the model simulation - type(c_ptr), intent(in), value :: handle_startTime ! start time for the model simulation - type(c_ptr), intent(in), value :: handle_oldTime ! time for the previous model time step - real(c_double),intent(inout) :: upArea - integer(c_int),intent(inout) :: err - - ! local variables - type(var_d),pointer :: attrStruct ! local attributes for each HRU - type(var_i),pointer :: typeStruct ! local classification of soil veg etc. for each HRU - type(var_i8),pointer :: idStruct ! - type(var_dlength),pointer :: mparStruct ! model parameters - type(var_d),pointer :: bparStruct ! basin-average parameters - type(var_dlength),pointer :: bvarStruct ! basin-average variables - type(var_d),pointer :: dparStruct ! default model parameters - type(zLookup),pointer :: lookupStruct ! default model parameters - type(var_i),pointer :: startTime ! start time for the model simulation - type(var_i),pointer :: oldTime ! time for the previous model time step - character(len=256) :: message ! error message - character(len=256) :: cmessage ! error message of downwind routine - - ! --------------------------------------------------------------------------------------- - ! initialize error control - err=0; message='setupHRUParam/' - - ! convert to fortran pointer from C++ pointer - call c_f_pointer(handle_attrStruct, attrStruct) - call c_f_pointer(handle_typeStruct, typeStruct) - call c_f_pointer(handle_idStruct, idStruct) - call c_f_pointer(handle_mparStruct, mparStruct) - call c_f_pointer(handle_bparStruct, bparStruct) - call c_f_pointer(handle_bvarStruct, bvarStruct) - call c_f_pointer(handle_dparStruct, dparStruct) - call c_f_pointer(handle_lookupStruct, lookupStruct) - call c_f_pointer(handle_startTime, startTime) - call c_f_pointer(handle_oldTime, oldTime) - - ! ffile_info and mDecisions moved to their own seperate subroutine call - - oldTime%var(:) = startTime%var(:) - - ! get the maximum number of snow layers - select case(model_decisions(iLookDECISIONS%snowLayers)%iDecision) - case(sameRulesAllLayers); maxSnowLayers = 100 - case(rulesDependLayerIndex); maxSnowLayers = 5 - case default; err=20; - message=trim(message)//'unable to identify option to combine/sub-divide snow layers' - print*, message - return - end select ! (option to combine/sub-divide snow layers) - - ! get the maximum number of layers - maxLayers = gru_struc(1)%hruInfo(1)%nSoil + maxSnowLayers - - ! define monthly fraction of green vegetation - greenVegFrac_monthly = (/0.01_dp, 0.02_dp, 0.03_dp, 0.07_dp, 0.50_dp, 0.90_dp, 0.95_dp, 0.96_dp, 0.65_dp, 0.24_dp, 0.11_dp, 0.02_dp/) - - ! define urban vegetation category - select case(trim(model_decisions(iLookDECISIONS%vegeParTbl)%cDecision)) - case('USGS'); urbanVegCategory = 1 - case('MODIFIED_IGBP_MODIS_NOAH'); urbanVegCategory = 13 - case('plumberCABLE'); urbanVegCategory = -999 - case('plumberCHTESSEL'); urbanVegCategory = -999 - case('plumberSUMMA'); urbanVegCategory = -999 - case default - message=trim(message)//'unable to identify vegetation category' - print*, message - return - end select - - ! ***************************************************************************** - ! *** compute derived model variables that are pretty much constant for the basin as a whole - ! ***************************************************************************** - ! calculate the fraction of runoff in future time steps - call fracFuture(bparStruct%var, & ! vector of basin-average model parameters - bvarStruct, & ! data structure of basin-average variables - err,cmessage) ! error control - if(err/=0)then;message=trim(message)//trim(cmessage);print*,message;return;endif - - ! check that the parameters are consistent - call paramCheck(mparStruct,err,cmessage) - if(err/=0)then;message=trim(message)//trim(cmessage);print*,message;return;endif - - ! calculate a look-up table for the temperature-enthalpy conversion - call E2T_lookup(mparStruct,err,cmessage) - if(err/=0)then;message=trim(message)//trim(cmessage);print*, message;return;endif - - ! overwrite the vegetation height - HVT(typeStruct%var(iLookTYPE%vegTypeIndex)) = mparStruct%var(iLookPARAM%heightCanopyTop)%dat(1) - HVB(typeStruct%var(iLookTYPE%vegTypeIndex)) = mparStruct%var(iLookPARAM%heightCanopyBottom)%dat(1) - - ! overwrite the tables for LAI and SAI - if(model_decisions(iLookDECISIONS%LAI_method)%iDecision == specified)then - SAIM(typeStruct%var(iLookTYPE%vegTypeIndex),:) = mparStruct%var(iLookPARAM%winterSAI)%dat(1) - LAIM(typeStruct%var(iLookTYPE%vegTypeIndex),:) = mparStruct%var(iLookPARAM%summerLAI)%dat(1)*greenVegFrac_monthly - endif - - ! compute total area of the upstream HRUS that flow into each HRU - upArea = 0._dp - ! Check if lateral flows exists within the HRU - if(typeStruct%var(iLookTYPE%downHRUindex)==typeStruct%var(iLookID%hruId))then - upArea = upArea + attrStruct%var(iLookATTR%HRUarea) - endif - - ! identify the total basin area for a GRU (m2) - associate(totalArea => bvarStruct%var(iLookBVAR%basin__totalArea)%dat(1) ) - totalArea = 0._dp - totalArea = totalArea + attrStruct%var(iLookATTR%HRUarea) - end associate - -end subroutine setupHRUParam - -! ************************************************************************************************** -! private subroutine SOIL_VEG_GEN_PARM: Read soil, vegetation and other model parameters (from NOAH) -! ************************************************************************************************** -!----------------------------------------------------------------- -SUBROUTINE SOIL_VEG_GEN_PARM(FILENAME_VEGTABLE, FILENAME_SOILTABLE, FILENAME_GENERAL, MMINLU, MMINSL) - !----------------------------------------------------------------- - use module_sf_noahlsm, only : shdtbl, nrotbl, rstbl, rgltbl, & - & hstbl, snuptbl, maxalb, laimintbl, & - & bb, drysmc, f11, maxsmc, laimaxtbl, & - & emissmintbl, emissmaxtbl, albedomintbl, & - & albedomaxtbl, wltsmc, qtz, refsmc, & - & z0mintbl, z0maxtbl, & - & satpsi, satdk, satdw, & - & theta_res, theta_sat, vGn_alpha, vGn_n, k_soil, & ! MPC add van Genutchen parameters - & fxexp_data, lvcoef_data, & - & lutype, maxalb, & - & slope_data, frzk_data, bare, cmcmax_data, & - & cfactr_data, csoil_data, czil_data, & - & refkdt_data, natural, refdk_data, & - & rsmax_data, salp_data, sbeta_data, & - & zbot_data, smhigh_data, smlow_data, & - & lucats, topt_data, slcats, slpcats, sltype - - IMPLICIT NONE - - CHARACTER(LEN=*), INTENT(IN) :: FILENAME_VEGTABLE, FILENAME_SOILTABLE, FILENAME_GENERAL - CHARACTER(LEN=*), INTENT(IN) :: MMINLU, MMINSL - integer :: LUMATCH, IINDEX, LC, NUM_SLOPE - integer :: ierr - INTEGER , PARAMETER :: OPEN_OK = 0 - - character*128 :: mess , message - - !-----SPECIFY VEGETATION RELATED CHARACTERISTICS : - ! ALBBCK: SFC albedo (in percentage) - ! Z0: Roughness length (m) - ! SHDFAC: Green vegetation fraction (in percentage) - ! Note: The ALBEDO, Z0, and SHDFAC values read from the following table - ! ALBEDO, amd Z0 are specified in LAND-USE TABLE; and SHDFAC is - ! the monthly green vegetation data - ! CMXTBL: MAX CNPY Capacity (m) - ! NROTBL: Rooting depth (layer) - ! RSMIN: Mimimum stomatal resistance (s m-1) - ! RSMAX: Max. stomatal resistance (s m-1) - ! RGL: Parameters used in radiation stress function - ! HS: Parameter used in vapor pressure deficit functio - ! TOPT: Optimum transpiration air temperature. (K) - ! CMCMAX: Maximum canopy water capacity - ! CFACTR: Parameter used in the canopy inteception calculati - ! SNUP: Threshold snow depth (in water equivalent m) that - ! implies 100% snow cover - ! LAI: Leaf area index (dimensionless) - ! MAXALB: Upper bound on maximum albedo over deep snow - ! - !-----READ IN VEGETAION PROPERTIES FROM VEGPARM.TBL - ! - - OPEN(19, FILE=trim(FILENAME_VEGTABLE),FORM='FORMATTED',STATUS='OLD',IOSTAT=ierr) - IF(ierr .NE. OPEN_OK ) THEN - WRITE(message,FMT='(A)') & - 'module_sf_noahlsm.F: soil_veg_gen_parm: failure opening VEGPARM.TBL' - CALL wrf_error_fatal ( message ) - END IF - - LUMATCH=0 - - FIND_LUTYPE : DO WHILE (LUMATCH == 0) - READ (19,*,END=2002) - READ (19,*,END=2002)LUTYPE - READ (19,*)LUCATS,IINDEX - - IF(LUTYPE.EQ.MMINLU)THEN - WRITE( mess , * ) 'LANDUSE TYPE = ' // TRIM ( LUTYPE ) // ' FOUND', LUCATS,' CATEGORIES' - ! CALL wrf_message( mess ) - LUMATCH=1 - ELSE - ! call wrf_message ( "Skipping over LUTYPE = " // TRIM ( LUTYPE ) ) - DO LC = 1, LUCATS+12 - read(19,*) - ENDDO - ENDIF - ENDDO FIND_LUTYPE - ! prevent possible array overwrite, Bill Bovermann, IBM, May 6, 2008 - IF ( SIZE(SHDTBL) < LUCATS .OR. & - SIZE(NROTBL) < LUCATS .OR. & - SIZE(RSTBL) < LUCATS .OR. & - SIZE(RGLTBL) < LUCATS .OR. & - SIZE(HSTBL) < LUCATS .OR. & - SIZE(SNUPTBL) < LUCATS .OR. & - SIZE(MAXALB) < LUCATS .OR. & - SIZE(LAIMINTBL) < LUCATS .OR. & - SIZE(LAIMAXTBL) < LUCATS .OR. & - SIZE(Z0MINTBL) < LUCATS .OR. & - SIZE(Z0MAXTBL) < LUCATS .OR. & - SIZE(ALBEDOMINTBL) < LUCATS .OR. & - SIZE(ALBEDOMAXTBL) < LUCATS .OR. & - SIZE(EMISSMINTBL ) < LUCATS .OR. & - SIZE(EMISSMAXTBL ) < LUCATS ) THEN - CALL wrf_error_fatal('Table sizes too small for value of LUCATS in module_sf_noahdrv.F') - ENDIF - - IF(LUTYPE.EQ.MMINLU)THEN - DO LC=1,LUCATS - READ (19,*)IINDEX,SHDTBL(LC), & - NROTBL(LC),RSTBL(LC),RGLTBL(LC),HSTBL(LC), & - SNUPTBL(LC),MAXALB(LC), LAIMINTBL(LC), & - LAIMAXTBL(LC),EMISSMINTBL(LC), & - EMISSMAXTBL(LC), ALBEDOMINTBL(LC), & - ALBEDOMAXTBL(LC), Z0MINTBL(LC), Z0MAXTBL(LC) - ENDDO - - READ (19,*) - READ (19,*)TOPT_DATA - READ (19,*) - READ (19,*)CMCMAX_DATA - READ (19,*) - READ (19,*)CFACTR_DATA - READ (19,*) - READ (19,*)RSMAX_DATA - READ (19,*) - READ (19,*)BARE - READ (19,*) - READ (19,*)NATURAL - ENDIF - -2002 CONTINUE - - CLOSE (19) - IF (LUMATCH == 0) then - CALL wrf_error_fatal ("Land Use Dataset '"//MMINLU//"' not found in VEGPARM.TBL.") - ENDIF - -! -!-----READ IN SOIL PROPERTIES FROM SOILPARM.TBL -! - OPEN(19, FILE=trim(FILENAME_SOILTABLE),FORM='FORMATTED',STATUS='OLD',IOSTAT=ierr) - IF(ierr .NE. OPEN_OK ) THEN - WRITE(message,FMT='(A)') & - 'module_sf_noahlsm.F: soil_veg_gen_parm: failure opening SOILPARM.TBL' - CALL wrf_error_fatal ( message ) - END IF - - WRITE(mess,*) 'INPUT SOIL TEXTURE CLASSIFICATION = ', TRIM ( MMINSL ) - ! CALL wrf_message( mess ) - - LUMATCH=0 - - ! MPC add a new soil table - FIND_soilTYPE : DO WHILE (LUMATCH == 0) - READ (19,*) - READ (19,*,END=2003)SLTYPE - READ (19,*)SLCATS,IINDEX - IF(SLTYPE.EQ.MMINSL)THEN - WRITE( mess , * ) 'SOIL TEXTURE CLASSIFICATION = ', TRIM ( SLTYPE ) , ' FOUND', & - SLCATS,' CATEGORIES' - ! CALL wrf_message ( mess ) - LUMATCH=1 - ELSE - ! call wrf_message ( "Skipping over SLTYPE = " // TRIM ( SLTYPE ) ) - DO LC = 1, SLCATS - read(19,*) - ENDDO - ENDIF - ENDDO FIND_soilTYPE - ! prevent possible array overwrite, Bill Bovermann, IBM, May 6, 2008 - IF ( SIZE(BB ) < SLCATS .OR. & - SIZE(DRYSMC) < SLCATS .OR. & - SIZE(F11 ) < SLCATS .OR. & - SIZE(MAXSMC) < SLCATS .OR. & - SIZE(REFSMC) < SLCATS .OR. & - SIZE(SATPSI) < SLCATS .OR. & - SIZE(SATDK ) < SLCATS .OR. & - SIZE(SATDW ) < SLCATS .OR. & - SIZE(WLTSMC) < SLCATS .OR. & - SIZE(QTZ ) < SLCATS ) THEN - CALL wrf_error_fatal('Table sizes too small for value of SLCATS in module_sf_noahdrv.F') - ENDIF - - ! MPC add new soil table - select case(trim(SLTYPE)) - case('STAS','STAS-RUC') ! original soil tables - DO LC=1,SLCATS - READ (19,*) IINDEX,BB(LC),DRYSMC(LC),F11(LC),MAXSMC(LC),& - REFSMC(LC),SATPSI(LC),SATDK(LC), SATDW(LC), & - WLTSMC(LC), QTZ(LC) - ENDDO - case('ROSETTA') ! new soil table - DO LC=1,SLCATS - READ (19,*) IINDEX,& - ! new soil parameters (from Rosetta) - theta_res(LC), theta_sat(LC), & - vGn_alpha(LC), vGn_n(LC), k_soil(LC), & - ! original soil parameters - BB(LC),DRYSMC(LC),F11(LC),MAXSMC(LC),& - REFSMC(LC),SATPSI(LC),SATDK(LC), SATDW(LC), & - WLTSMC(LC), QTZ(LC) - ENDDO - case default - CALL wrf_message( 'SOIL TEXTURE IN INPUT FILE DOES NOT ' ) - CALL wrf_message( 'MATCH SOILPARM TABLE' ) - CALL wrf_error_fatal ( 'INCONSISTENT OR MISSING SOILPARM FILE' ) - end select - -2003 CONTINUE - - CLOSE (19) - - IF(LUMATCH.EQ.0)THEN - CALL wrf_message( 'SOIL TEXTURE IN INPUT FILE DOES NOT ' ) - CALL wrf_message( 'MATCH SOILPARM TABLE' ) - CALL wrf_error_fatal ( 'INCONSISTENT OR MISSING SOILPARM FILE' ) - ENDIF - -! -!-----READ IN GENERAL PARAMETERS FROM GENPARM.TBL -! - OPEN(19, FILE=trim(FILENAME_GENERAL),FORM='FORMATTED',STATUS='OLD',IOSTAT=ierr) - IF(ierr .NE. OPEN_OK ) THEN - WRITE(message,FMT='(A)') & - 'module_sf_noahlsm.F: soil_veg_gen_parm: failure opening GENPARM.TBL' - CALL wrf_error_fatal ( message ) - END IF - - READ (19,*) - READ (19,*) - READ (19,*) NUM_SLOPE - - SLPCATS=NUM_SLOPE -! prevent possible array overwrite, Bill Bovermann, IBM, May 6, 2008 - IF ( SIZE(slope_data) < NUM_SLOPE ) THEN - CALL wrf_error_fatal('NUM_SLOPE too large for slope_data array in module_sf_noahdrv') - ENDIF - - DO LC=1,SLPCATS - READ (19,*)SLOPE_DATA(LC) - ENDDO - - READ (19,*) - READ (19,*)SBETA_DATA - READ (19,*) - READ (19,*)FXEXP_DATA - READ (19,*) - READ (19,*)CSOIL_DATA - READ (19,*) - READ (19,*)SALP_DATA - READ (19,*) - READ (19,*)REFDK_DATA - READ (19,*) - READ (19,*)REFKDT_DATA - READ (19,*) - READ (19,*)FRZK_DATA - READ (19,*) - READ (19,*)ZBOT_DATA - READ (19,*) - READ (19,*)CZIL_DATA - READ (19,*) - READ (19,*)SMLOW_DATA - READ (19,*) - READ (19,*)SMHIGH_DATA - READ (19,*) - READ (19,*)LVCOEF_DATA - CLOSE (19) - -!----------------------------------------------------------------- -END SUBROUTINE SOIL_VEG_GEN_PARM -!----------------------------------------------------------------- - -end module SummaActors_setup \ No newline at end of file diff --git a/utils/extra_scripts/makefile-container b/utils/extra_scripts/makefile-container index 0f30d90..4bc612d 100644 --- a/utils/extra_scripts/makefile-container +++ b/utils/extra_scripts/makefile-container @@ -163,7 +163,7 @@ SUMMA_PRELIM= \ checkStruc.f90 \ childStruc.f90 \ ffile_info.f90 \ - read_attribute.f90 \ + read_attrb.f90 \ read_pinit.f90 \ pOverwrite.f90 \ read_paramActors.f90 \ @@ -186,7 +186,7 @@ SUMMA_MODRUN = \ getVectorz.f90 \ updateVars.f90 \ var_derive.f90 \ - read_forcingActors.f90 \ + read_forceActors.f90 \ access_forcing.f90\ access_write.f90 \ derivforce.f90 \ @@ -206,7 +206,7 @@ MODRUN = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_MODRUN)) SUMMA_NETCDF = \ netcdf_util.f90 \ def_output.f90 \ - outputStrucWrite.f90 \ + hru_modelwrite.f90 \ writeOutput.f90 \ read_icondActors.f90 NETCDF = $(patsubst %, $(NETCDF_DIR)/%, $(SUMMA_NETCDF)) -- GitLab