diff --git a/build/includes/global/fortran_data_types.hpp b/build/includes/global/fortran_data_types.hpp index 7552b971c55fe790187cb7445494de767a40529b..e6833991804632b599eac275b055d8c48deeaf13 100644 --- a/build/includes/global/fortran_data_types.hpp +++ b/build/includes/global/fortran_data_types.hpp @@ -96,4 +96,7 @@ extern "C" { void* new_handle_file_info(); void delete_handle_file_info(void* handle); + // zLookup + void* new_handle_z_lookup(); + } \ No newline at end of file diff --git a/build/includes/hru_actor/hru_actor.hpp b/build/includes/hru_actor/hru_actor.hpp index 2f4c8d9b6bd3f01cb23826997be4750ffc2d82cb..cb0b7257ebc1748af3cc530fffbc9f2a2fa058bb 100644 --- a/build/includes/hru_actor/hru_actor.hpp +++ b/build/includes/hru_actor/hru_actor.hpp @@ -53,7 +53,11 @@ struct hru_state { void *handle_bvarStruct = new_handle_var_dlength(); // basin-average variables // ancillary data structures void *handle_dparStruct = new_handle_var_d(); // default model parameters - // Local hru data + // sundials type + void *handle_lookupStruct = new_handle_z_lookup(); + + + // Local hru data void *handle_ncid = new_handle_var_i(); // output file ids void *handle_statCounter = new_handle_var_i(); void *handle_outputTimeStep = new_handle_var_i(); diff --git a/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp b/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp index 9ffdece737faab27373735d56346926a8be30a15..c625ca30cd0f9bea11b4ad86b3dea8aae5dd0099 100644 --- a/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp +++ b/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp @@ -2,8 +2,8 @@ extern "C" { // Initialize HRU data_structures - void summaActors_initialize( - int* indxGRU, int* num_steps, + void initHRU( + int* indxGRU, int* num_steps, void* lookupStruct, // Statistics Structures void* forcStat, void* progStat, void* diagStat, void* fluxStat, void* indxStat, void* bvarStat, // Primary Data Structures (scalars) @@ -16,18 +16,6 @@ extern "C" { void* dparStruct, // local HRU data void* startTime, void* finshTime, void* refTime, void* oldTime, int* err); - - // SetupParam for HRU - // void SetupParam( - // int* indxGRU, int* indxHRU, - // // primary data structures (scalars) - // void* attrStruct, void* typeStruct, void* idStruct, - // // primary data structures (variable length vectors) - // void* mparStruct, void* bparStruct, void* bvarStruct, void* dparStruct, - // // local HRU data - // void* startTime, void* oldTime, - // // miscellaneous - // double* upArea, int* err); void setupHRUParam( int* indxGRU, int* indxHRU, // primary data structures (scalars) diff --git a/build/makefile b/build/makefile index 652faa716ea7e4d93d2bc186196b9121fb824862..9b984db055949643e91dc36e78d8fe33c0932a2b 100644 --- a/build/makefile +++ b/build/makefile @@ -234,7 +234,7 @@ SUMMA_DRIVER= \ summaActors_type.f90 \ summaActors_util.f90 \ summaActors_globalData.f90 \ - summaActors_init.f90 \ + init_hru_actor.f90 \ SummaActors_setup.f90 \ summaActors_restart.f90 \ summaActors_forcing.f90 \ diff --git a/build/makefile_sundials b/build/makefile_sundials index 1c3c352f33286197c7c2b513e3c3b8a682d0769d..fdb0785c1d581c58e6814372a0e206271c3d3acd 100644 --- a/build/makefile_sundials +++ b/build/makefile_sundials @@ -239,7 +239,7 @@ SUMMA_DRIVER= \ summaActors_type.f90 \ summaActors_util.f90 \ summaActors_globalData.f90 \ - summaActors_init.f90 \ + init_hru_actor.f90 \ SummaActors_setup.f90 \ summaActors_restart.f90 \ summaActors_forcing.f90 \ diff --git a/build/source/actors/global/cppwrap_datatypes.f90 b/build/source/actors/global/cppwrap_datatypes.f90 index b53ad96c61e744792ebada9cd6e3c3861adc7d69..418b6f4b17411f8e24b4c230f40a020f0c91973b 100644 --- a/build/source/actors/global/cppwrap_datatypes.f90 +++ b/build/source/actors/global/cppwrap_datatypes.f90 @@ -1057,6 +1057,15 @@ subroutine delete_handle_file_info(handle) bind(C, name='delete_handle_file_info end subroutine delete_handle_file_info ! ***************************** file_info *************************** + +! ****************************** z_lookup **************************** +function new_handle_z_lookup() result(handle) bind(C, name="new_handle_z_lookup") + type(c_ptr) :: handle + type(zLookup), pointer :: p + + allocate(p) + handle = c_loc(p) +end function end module cppwrap_datatypes diff --git a/build/source/actors/hru_actor/hru_actor.cpp b/build/source/actors/hru_actor/hru_actor.cpp index 225872061ce8028b81223dd9b9250cc56d3b6c63..0a62507f66e85c3bae0febc950c3b573e9e39521 100644 --- a/build/source/actors/hru_actor/hru_actor.cpp +++ b/build/source/actors/hru_actor/hru_actor.cpp @@ -152,8 +152,9 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, void Initialize_HRU(stateful_actor<hru_state>* self) { self->state.hru_timing.updateStartPoint("init_duration"); - summaActors_initialize(&self->state.indxGRU, + initHRU(&self->state.indxGRU, &self->state.num_steps, + self->state.handle_lookupStruct, self->state.handle_forcStat, self->state.handle_progStat, self->state.handle_diagStat, diff --git a/build/source/driver/summaActors_init.f90 b/build/source/driver/init_hru_actor.f90 similarity index 95% rename from build/source/driver/summaActors_init.f90 rename to build/source/driver/init_hru_actor.f90 index c95de9daa4c37fd1eaa4fe1adc5378f7bea7de71..961c385b8f38cc61728999188103af433913ddc4 100755 --- a/build/source/driver/summaActors_init.f90 +++ b/build/source/driver/init_hru_actor.f90 @@ -1,4 +1,4 @@ -module summaActors_init +module INIT_HRU_ACTOR ! used to declare and allocate summa data structures and initialize model state to known values USE,intrinsic :: iso_c_binding USE nrtype ! variable types, etc. @@ -8,7 +8,8 @@ USE data_types,only:& var_i8, & ! x%var(:) (i8b) var_d, & ! x%var(:) (dp) var_ilength, & ! x%var(:)%dat (i4b) - var_dlength ! x%var(:)%dat (dp) + var_dlength, & ! x%var(:)%dat (dp) + zLookup ! x%z(:)%var(:)%lookup(:) -- lookup tables ! access missing values USE globalData,only:integerMissing ! missing integer @@ -21,6 +22,8 @@ USE globalData,only:prog_meta,diag_meta,flux_meta,id_meta ! metadata structure USE globalData,only:mpar_meta,indx_meta ! metadata structures USE globalData,only:bpar_meta,bvar_meta ! metadata structures USE globalData,only:averageFlux_meta ! metadata for time-step average fluxes +USE globalData,only:lookup_meta + ! statistics metadata structures USE globalData,only:statForc_meta ! child metadata for stats USE globalData,only:statProg_meta ! child metadata for stats @@ -34,13 +37,14 @@ USE var_lookup,only:maxVarFreq ! # of available ou ! safety: set private unless specified otherwise implicit none private -public::summaActors_initialize +public::initHRU contains ! used to declare and allocate summa data structures and initialize model state to known values - subroutine summaActors_initialize(& + subroutine initHRU(& indxGRU, & ! Index of HRU's GRU parent num_steps, & + handle_lookupStruct,& ! statistics structures handle_forcStat, & ! model forcing data handle_progStat, & ! model prognostic (state) variables @@ -71,7 +75,7 @@ contains handle_refTime, & ! reference time for the model simulation handle_oldTime, & ! time for the previous model time step ! miscellaneous variables - err) bind(C,name='summaActors_initialize') + err) bind(C,name='initHRU') ! --------------------------------------------------------------------------------------- ! * desired modules ! --------------------------------------------------------------------------------------- @@ -100,7 +104,9 @@ contains ! --------------------------------------------------------------------------------------- integer(c_int),intent(in) :: indxGRU ! indx of the parent GRU integer(c_int),intent(out) :: num_steps ! number of steps in model, local to the HRU - ! statistics structures + + type(c_ptr), intent(in), value :: handle_lookupStruct ! z(:)%var(:)%lookup(:) -- lookup tables + ! statistics structures type(c_ptr), intent(in), value :: handle_forcStat ! model forcing data type(c_ptr), intent(in), value :: handle_progStat ! model prognostic (state) variables type(c_ptr), intent(in), value :: handle_diagStat ! model diagnostic variables @@ -133,6 +139,7 @@ contains ! --------------------------------------------------------------------------------------- ! * Fortran Variables For Conversion ! --------------------------------------------------------------------------------------- + type(zLookup),pointer :: lookupStruct ! z(:)%var(:)%lookup(:) -- lookup tables type(var_dlength),pointer :: forcStat ! model forcing data type(var_dlength),pointer :: progStat ! model prognostic (state) variables type(var_dlength),pointer :: diagStat ! model diagnostic variables @@ -170,6 +177,7 @@ contains ! --------------------------------------------------------------------------------------- ! * Convert From C++ to Fortran ! --------------------------------------------------------------------------------------- + call c_f_pointer(handle_lookupStruct, lookupStruct) call c_f_pointer(handle_forcStat, forcStat) call c_f_pointer(handle_progStat, progStat) call c_f_pointer(handle_diagStat, diagStat) @@ -252,12 +260,14 @@ contains case('flux'); call allocLocal(flux_meta,fluxStruct,nSnow,nSoil,err,cmessage); ! model fluxes case('bpar'); call allocLocal(bpar_meta,bparStruct,nSnow=0,nSoil=0,err=err,message=cmessage); ! basin-average params case('bvar'); call allocLocal(bvar_meta,bvarStruct,nSnow=0,nSoil=0,err=err,message=cmessage); ! basin-average variables + case('lookup'); call allocLocal(lookup_meta,lookupStruct,err=err,message=cmessage) ! basin-average variables case('deriv'); cycle case default; err=20; message='unable to find structure name: '//trim(structInfo(iStruct)%structName) end select ! check errors if(err/=0)then message=trim(message)//trim(cmessage)//'[structure = '//trim(structInfo(iStruct)%structName)//']' + print*, message return endif end do ! looping through data structures @@ -267,6 +277,7 @@ contains call allocLocal(mpar_meta,dparStruct,nSnow,nSoil,err,cmessage); ! default model parameters if(err/=0)then message=trim(message)//trim(cmessage)//' [problem allocating dparStruct]' + print*, message return endif @@ -288,6 +299,7 @@ contains ! check errors if(err/=0)then message=trim(message)//trim(cmessage)//'[statistics for = '//trim(structInfo(iStruct)%structName)//']' + print*, message return endif end do ! iStruct @@ -298,6 +310,6 @@ contains ! end association to info in data structures end associate - end subroutine summaActors_initialize + end subroutine initHRU -end module summaActors_init +end module INIT_HRU_ACTOR diff --git a/build/source/driver/summaActors_wOutputStruc.f90 b/build/source/driver/summaActors_wOutputStruc.f90 index 34f78b4478b38f98ebd0f93d39d749af650294bc..4ad7004c378fc55b96eb154d280fcd046f9d161a 100644 --- a/build/source/driver/summaActors_wOutputStruc.f90 +++ b/build/source/driver/summaActors_wOutputStruc.f90 @@ -168,6 +168,7 @@ subroutine summaActors_writeToOutputStruc(& integer(i4b) :: nHRU integer(i4b) :: iFreq ! index of the output frequency integer(i4b) :: iGRU ! Temporary index for GRU + integer(i4b) :: iDat nGRU = 1 nHRU = 1 iGRU = 1 @@ -233,9 +234,10 @@ subroutine summaActors_writeToOutputStruc(& outputTimeStep%var(:)=1 end if ! if defining a new file - ! copy finalized stats to output structure - outputStructure(1)%finalizeStats(1)%gru(indxGRU)%hru(indxHRU)%tim(outputStep)%dat(:) = finalizeStats%dat(:) - + ! If we do not do this looping we segfault - I am not sure why + do iDat=1,size(outputStructure(1)%finalizeStats(1)%gru(indxGRU)%hru(indxHRU)%tim(outputStep)%dat) + outputStructure(1)%finalizeStats(1)%gru(indxGRU)%hru(indxHRU)%tim(outputStep)%dat(iDat) = finalizeStats%dat(iDat) + end do ! **************************************************************************** ! *** calculate output statistics ! **************************************************************************** diff --git a/build/source/dshare/get_ixname.f90 b/build/source/dshare/get_ixname.f90 index fbf9c4e3e37d3ac67a9c823f8e57f243f2379990..a7866a4b1d7f1fa3bcc96be8b038e689fc6f5060 100755 --- a/build/source/dshare/get_ixname.f90 +++ b/build/source/dshare/get_ixname.f90 @@ -997,6 +997,7 @@ contains case ('bpar' ); vDex = get_ixBpar(trim(varName)) case ('bvar' ); vDex = get_ixBvar(trim(varName)) case ('deriv'); vDex = get_ixDeriv(trim(varName)) + case ('lookup'); vDex = get_ixLookup(trim(varName)) end select if (vDex>0) then; typeName=trim(structInfo(iStruc)%structName); return; end if end do @@ -1006,6 +1007,26 @@ contains end subroutine get_ixUnknown +! ******************************************************************************************************************* +! public function get_ixfreq: get the index of the named variables for the output frequencies +! ******************************************************************************************************************* +function get_ixLookup(varName) + USE var_lookup,only:iLookLOOKUP ! indices of the named variables + implicit none + ! define dummy variables + character(*), intent(in) :: varName ! variable name + integer(i4b) :: get_ixLookup ! index of the named variable + ! get the index of the named variables + select case(trim(varName)) + case('temperature'); get_ixLookup = iLookLOOKUP%temperature ! temperature (K) + case('enthalpy' ); get_ixLookup = iLookLOOKUP%enthalpy ! enthalpy (J m-3) + case('deriv2' ); get_ixLookup = iLookLOOKUP%deriv2 ! secind derivative of the interpolating function + ! get to here if cannot find the variable + case default + get_ixLookup = integerMissing + end select + end function get_ixLookup + ! ******************************************************************************************************************* ! public function get_ixfreq: get the index of the named variables for the output frequencies ! ******************************************************************************************************************* diff --git a/build/source/dshare/globalData.f90 b/build/source/dshare/globalData.f90 index b1dc1ee5b560396e43e46c8a1d949d4371e35bfe..205788e200250c50aa5686176dc792977edccae1 100755 --- a/build/source/dshare/globalData.f90 +++ b/build/source/dshare/globalData.f90 @@ -60,6 +60,7 @@ MODULE globalData USE var_lookup,only:maxvarBpar ! basin-average parameters: maximum number variables USE var_lookup,only:maxvarDecisions ! maximum number of decisions USE var_lookup,only:maxvarFreq ! maximum number of output files + USE var_lookup,only:maxvarLookup implicit none private @@ -148,7 +149,7 @@ MODULE globalData real(rkind),parameter,public :: dx = 1.e-8_dp ! finite difference increment ! define summary information on all data structures - integer(i4b),parameter :: nStruct=13 ! number of data structures + integer(i4b),parameter :: nStruct=14 ! number of data structures type(struct_info),parameter,public,dimension(nStruct) :: structInfo=(/& struct_info('time', 'TIME' , maxvarTime ), & ! the time data structure struct_info('forc', 'FORCE', maxvarForc ), & ! the forcing data structure @@ -162,8 +163,8 @@ MODULE globalData struct_info('prog', 'PROG', maxvarProg ), & ! the prognostic (state) variable data structure struct_info('diag', 'DIAG' , maxvarDiag ), & ! the diagnostic variable data structure struct_info('flux', 'FLUX' , maxvarFlux ), & ! the flux data structure - struct_info('deriv', 'DERIV', maxvarDeriv) /) ! the model derivative data structure - + struct_info('deriv', 'DERIV', maxvarDeriv), & ! the model derivative data structure + struct_info('lookup', 'LOOKUP',maxvarLookup) /) ! fixed model decisions logical(lgt) , parameter, public :: overwriteRSMIN=.false. ! flag to overwrite RSMIN integer(i4b) , parameter, public :: maxSoilLayers=10000 ! Maximum Number of Soil Layers @@ -191,6 +192,7 @@ MODULE globalData type(var_info),save,public :: diag_meta(maxvarDiag) ! local diagnostic variables for each HRU type(var_info),save,public :: flux_meta(maxvarFlux) ! local model fluxes for each HRU type(var_info),save,public :: deriv_meta(maxvarDeriv) ! local model derivatives for each HRU + type(var_info),save,public :: lookup_meta(maxvarLookup) ! local lookup tables for each HRU type(var_info),save,public :: bpar_meta(maxvarBpar) ! basin parameters for aggregated processes type(var_info),save,public :: bvar_meta(maxvarBvar) ! basin variables for aggregated processes diff --git a/build/source/dshare/popMetadat.f90 b/build/source/dshare/popMetadat.f90 index 4c2b371e64ea8dcb3f5294d6966f10242bc75e52..3ec9511f0bb717cd798eb9ff20bd5d96cc6c1df6 100755 --- a/build/source/dshare/popMetadat.f90 +++ b/build/source/dshare/popMetadat.f90 @@ -31,6 +31,7 @@ subroutine popMetadat(err,message) USE globalData, only: diag_meta ! data structure for local diagnostic variables USE globalData, only: flux_meta ! data structure for local flux variables USE globalData, only: deriv_meta ! data structure for local flux derivatives + USE globalData, only: lookup_meta ! data structure for lookup tables ! structures of named variables USE var_lookup, only: iLookTIME ! named variables for time data structure USE var_lookup, only: iLookFORCE ! named variables for forcing data structure @@ -45,6 +46,7 @@ subroutine popMetadat(err,message) USE var_lookup, only: iLookDIAG ! named variables for local diagnostic variables USE var_lookup, only: iLookFLUX ! named variables for local flux variables USE var_lookup, only: iLookDERIV ! named variables for local flux derivatives + USE var_lookup, only: iLookLOOKUP ! named variables for lookup tables USE var_lookup, only: maxvarFreq ! number of output frequencies USE var_lookup, only: maxvarStat ! number of statistics USE get_ixName_module,only:get_ixVarType ! to turn vartype strings to integers @@ -595,6 +597,15 @@ subroutine popMetadat(err,message) bvar_meta(iLookBVAR%averageInstantRunoff) = var_info('averageInstantRunoff' , 'instantaneous runoff' , 'm s-1' , get_ixVarType('scalarv'), iMissVec, iMissVec, .false.) bvar_meta(iLookBVAR%averageRoutedRunoff) = var_info('averageRoutedRunoff' , 'routed runoff' , 'm s-1' , get_ixVarType('scalarv'), iMissVec, iMissVec, .false.) + ! ----- + ! * lookup tables... + ! ------------------ + + ! temperature and enthalpy + lookup_meta(iLookLOOKUP%temperature) = var_info('temperature' , 'value of temperature in the lookup table' , 'K' , get_ixVarType('unknown'), iMissVec, iMissVec, .false.) + lookup_meta(iLookLOOKUP%enthalpy) = var_info('enthalpy' , 'value of enthalpy in the lookup table' , 'J m-3' , get_ixVarType('unknown'), iMissVec, iMissVec, .false.) + lookup_meta(iLookLOOKUP%deriv2) = var_info('deriv2' , 'second derivatives of the interpolating function' , 'mixed' , get_ixVarType('unknown'), iMissVec, iMissVec, .false.) + ! ----- ! * model indices... ! ------------------ diff --git a/build/source/dshare/var_lookup.f90 b/build/source/dshare/var_lookup.f90 index 9ae9d716b2e56839fc74e859bae0e6b5298e98b8..f1657613547a75f7a31b354caf2d9d743be0b063 100755 --- a/build/source/dshare/var_lookup.f90 +++ b/build/source/dshare/var_lookup.f90 @@ -758,6 +758,17 @@ MODULE var_lookup integer(i4b) :: timestep = integerMissing ! timestep-level output (no temporal aggregation) endtype iLook_freq + ! *********************************************************************************************************** + ! (16) structure for looking up lookup tables + ! *********************************************************************************************************** + type, public :: iLook_vLookup + integer(i4b) :: temperature = integerMissing ! temperature (K) + integer(i4b) :: enthalpy = integerMissing ! enthalpy (J m-3) + integer(i4b) :: deriv2 = integerMissing ! second derivatives of the interpolating function + endtype iLook_vLookup + + + ! *********************************************************************************************************** ! (X) define data structures and maximum number of variables of each type ! *********************************************************************************************************** @@ -857,6 +868,7 @@ MODULE var_lookup ! number of possible output frequencies type(iLook_freq), public,parameter :: iLookFreq =ilook_freq ( 1, 2, 3, 4) + type(iLook_vLookup), public,parameter :: iLookLOOKUP =ilook_vLookup ( 1, 2, 3) ! define maximum number of variables of each type integer(i4b),parameter,public :: maxvarDecisions = storage_size(iLookDECISIONS)/iLength integer(i4b),parameter,public :: maxvarTime = storage_size(iLookTIME)/iLength @@ -875,6 +887,7 @@ MODULE var_lookup integer(i4b),parameter,public :: maxvarVarType = storage_size(iLookVarType)/iLength integer(i4b),parameter,public :: maxvarStat = storage_size(iLookStat)/iLength integer(i4b),parameter,public :: maxvarFreq = storage_size(iLookFreq)/iLength + integer(i4b),parameter,public :: maxvarLookup = storage_size(iLookLOOKUP)/iLength ! *********************************************************************************************************** ! (Y) define ancillary look-up structures diff --git a/build/source/engine/allocspaceActors.f90 b/build/source/engine/allocspaceActors.f90 index f10d43a342c637095a54e68f3de963d41484f559..fcc30740e2eb3f758f243270126659f2ecd3fe19 100755 --- a/build/source/engine/allocspaceActors.f90 +++ b/build/source/engine/allocspaceActors.f90 @@ -25,6 +25,7 @@ USE nrtype ! provide access to the derived types to define the data structures USE data_types,only:& + zLookup, & ! final data vectors dlength, & ! var%dat ilength, & ! var%dat @@ -133,6 +134,7 @@ contains logical(lgt) :: check ! .true. if the variables are allocated integer(i4b) :: nVars ! number of variables in the metadata structure integer(i4b) :: nLayers ! total number of layers + logical(lgt) :: spatial character(len=256) :: cmessage ! error message of the downwind routine ! initialize error control err=0; message='allocLocal/' @@ -168,6 +170,7 @@ contains class is (var_flagVec); if(allocated(dataStruct%var))then; check=.true.; else; allocate(dataStruct%var(nVars),stat=err); end if class is (var_ilength); if(allocated(dataStruct%var))then; check=.true.; else; allocate(dataStruct%var(nVars),stat=err); end if class is (var_dlength); if(allocated(dataStruct%var))then; check=.true.; else; allocate(dataStruct%var(nVars),stat=err); end if + class is (zLookup); spatial=.true. class default; err=20; message=trim(message)//'unable to identify derived data type for the variable dimension'; return end select ! check errors @@ -179,6 +182,7 @@ contains class is (var_flagVec); call allocateDat_flag(metaStruct,nSnow,nSoil,nLayers,dataStruct,err,cmessage) class is (var_ilength); call allocateDat_int( metaStruct,nSnow,nSoil,nLayers,dataStruct,err,cmessage) class is (var_dlength); call allocateDat_dp( metaStruct,nSnow,nSoil,nLayers,dataStruct,err,cmessage) + class is (zLookup); spatial=.true. class default; err=20; message=trim(message)//'unable to identify derived data type for the data dimension'; return end select diff --git a/build/source/engine/checkStruc.f90 b/build/source/engine/checkStruc.f90 index 3d723a367f3e07189eae00fa46efff605ff398aa..8d7aa5da1e426f056b89c69755f26a0abe61f607 100755 --- a/build/source/engine/checkStruc.f90 +++ b/build/source/engine/checkStruc.f90 @@ -40,11 +40,13 @@ contains USE globalData,only:prog_meta,diag_meta,flux_meta,deriv_meta ! metadata structures USE globalData,only:mpar_meta,indx_meta ! metadata structures USE globalData,only:bpar_meta,bvar_meta ! metadata structures + USE globalData,only:lookup_meta ! metadata structures ! named variables defining strructure elements USE var_lookup,only:iLookTIME,iLookFORCE,iLookATTR,iLookTYPE,iLookID ! named variables showing the elements of each data structure USE var_lookup,only:iLookPROG,iLookDIAG,iLookFLUX,iLookDERIV ! named variables showing the elements of each data structure USE var_lookup,only:iLookPARAM,iLookINDEX ! named variables showing the elements of each data structure USE var_lookup,only:iLookBPAR,iLookBVAR ! named variables showing the elements of each data structure + USE var_lookup,only:iLookLOOKUP ! named variables showing the elements of each data structure implicit none ! dummy variables integer(i4b),intent(out) :: err ! error code @@ -83,6 +85,7 @@ contains case('diag'); write(longString,*) iLookDIAG case('flux'); write(longString,*) iLookFLUX case('deriv'); write(longString,*) iLookDERIV + case('lookup'); write(longString,*) iLookLOOKUP case default; err=20; message=trim(message)//'unable to identify lookup structure'; return end select ! check that the length of the lookup structure matches the number of variables in the data structure @@ -119,6 +122,7 @@ contains case('diag'); call checkPopulated(iStruct,diag_meta,err,cmessage) case('flux'); call checkPopulated(iStruct,flux_meta,err,cmessage) case('deriv'); call checkPopulated(iStruct,deriv_meta,err,cmessage) + case('lookup'); call checkPopulated(iStruct,lookup_meta,err,cmessage) case default; err=20; message=trim(message)//'unable to identify lookup structure'; return end select if(err/=0)then; message=trim(message)//trim(cmessage); return; end if ! (check for errors) diff --git a/build/source/engine/nrtype.mod b/build/source/engine/nrtype.mod index 66827afb4ddef1dc3741a7481196b45284785e98..cb753b75bed2441f7d23ae5b89340b7015376d91 100644 Binary files a/build/source/engine/nrtype.mod and b/build/source/engine/nrtype.mod differ diff --git a/build/source/netcdf/def_output.f90 b/build/source/netcdf/def_output.f90 index 59a6cae5264e43e22e8643c23ec79a2690f82b06..f4859f7c3b06243265bfd4e1845270dd503dcfdf 100755 --- a/build/source/netcdf/def_output.f90 +++ b/build/source/netcdf/def_output.f90 @@ -154,7 +154,11 @@ subroutine def_output(handle_ncid,startGRU,nGRU,nHRU,err) bind(C, name='def_outp do iFreq=1,maxvarFreq if (ncid%var(iFreq)/=integerMissing) then call nc_file_close(ncid%var(iFreq),err,cmessage) - if(err/=0)then; message=trim(message)//trim(cmessage); return; end if + if(err/=0)then + message=trim(message)//trim(cmessage) + print*, message + return + end if endif end do @@ -171,39 +175,58 @@ subroutine def_output(handle_ncid,startGRU,nGRU,nHRU,err) bind(C, name='def_outp fstring = get_freqName(iFreq) fname = trim(fileout)//'_'//trim(fstring)//'.nc' call ini_create(nGRU,nHRU,gru_struc(1)%hruInfo(1)%nSoil,trim(fname),ncid%var(iFreq),err,cmessage) - if(err/=0)then; message=trim(message)//trim(cmessage); return; end if + if(err/=0)then + message=trim(message)//trim(cmessage) + print*, message + return + end if ! define model decisions do iVar = 1,size(model_decisions) if(model_decisions(iVar)%iDecision.ne.integerMissing)then call put_attrib(ncid%var(iFreq),model_decisions(iVar)%cOption,model_decisions(iVar)%cDecision,err,cmessage) - if(err/=0)then; message=trim(message)//trim(cmessage); return; end if + if(err/=0)then + message=trim(message)//trim(cmessage) + print*, message + return + end if end if end do ! define variables do iStruct = 1,size(structInfo) select case (trim(structInfo(iStruct)%structName)) - case('attr' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,attr_meta, outputPrecision, err,cmessage) ! local attributes HRU - case('type' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,type_meta, nf90_int, err,cmessage) ! local classification - case('mpar' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,mpar_meta, outputPrecision, err,cmessage) ! model parameters - case('bpar' ); call def_variab(ncid%var(iFreq),iFreq,needGRU, noTime,bpar_meta, outputPrecision, err,cmessage) ! basin-average param - case('indx' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,indx_meta, nf90_int, err,cmessage) ! model variables - case('deriv'); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,deriv_meta,outputPrecision, err,cmessage) ! model derivatives - case('time' ); call def_variab(ncid%var(iFreq),iFreq, noHRU,needTime,time_meta, nf90_int, err,cmessage) ! model derivatives - case('forc' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,forc_meta, outputPrecision, err,cmessage) ! model forcing data - case('prog' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,prog_meta, outputPrecision, err,cmessage) ! model prognostics - case('diag' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,diag_meta, outputPrecision, err,cmessage) ! model diagnostic variables - case('flux' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,flux_meta, outputPrecision, err,cmessage) ! model fluxes - case('bvar' ); call def_variab(ncid%var(iFreq),iFreq,needGRU,needTime,bvar_meta, outputPrecision, err,cmessage) ! basin-average variables - case('id' ); cycle ! ids -- see write_hru_info() + case('attr' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,attr_meta, outputPrecision, err,cmessage) ! local attributes HRU + case('type' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,type_meta, nf90_int, err,cmessage) ! local classification + case('mpar' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,mpar_meta, outputPrecision, err,cmessage) ! model parameters + case('bpar' ); call def_variab(ncid%var(iFreq),iFreq,needGRU, noTime,bpar_meta, outputPrecision, err,cmessage) ! basin-average param + case('indx' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,indx_meta, nf90_int, err,cmessage) ! model variables + case('deriv' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,deriv_meta,outputPrecision, err,cmessage) ! model derivatives + case('time' ); call def_variab(ncid%var(iFreq),iFreq, noHRU,needTime,time_meta, nf90_int, err,cmessage) ! model derivatives + case('forc' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,forc_meta, outputPrecision, err,cmessage) ! model forcing data + case('prog' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,prog_meta, outputPrecision, err,cmessage) ! model prognostics + case('diag' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,diag_meta, outputPrecision, err,cmessage) ! model diagnostic variables + case('flux' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,flux_meta, outputPrecision, err,cmessage) ! model fluxes + case('bvar' ); call def_variab(ncid%var(iFreq),iFreq,needGRU,needTime,bvar_meta, outputPrecision, err,cmessage) ! basin-average variables + case('id' ); cycle + case('lookup'); cycle ! ids -- see write_hru_info() case default; err=20; message=trim(message)//'unable to identify lookup structure'; end select ! error handling - if(err/=0)then;err=20;message=trim(message)//trim(cmessage)//'[structure = '//trim(structInfo(iStruct)%structName);return;end if + if(err/=0)then + err=20 + message=trim(message)//trim(cmessage)//'[structure = '//trim(structInfo(iStruct)%structName) + print*, message + return + end if end do ! iStruct ! write HRU dimension and ID for each output file - call write_hru_info(ncid%var(iFreq), err, cmessage); if(err/=0) then; message=trim(message)//trim(cmessage); return; end if + call write_hru_info(ncid%var(iFreq), err, cmessage) + if(err/=0) then + message=trim(message)//trim(cmessage) + print*, message + return + end if end do end subroutine def_output diff --git a/utils/containers/sundials/launch_docker_container.sh b/utils/containers/sundials/launch_docker_container.sh index 4acc705ed4cbf9591cf370daae6f27bb0d32d555..5d8de7e55a5932a71004caa5b1c74757e6af968c 100755 --- a/utils/containers/sundials/launch_docker_container.sh +++ b/utils/containers/sundials/launch_docker_container.sh @@ -3,5 +3,5 @@ export PROJECT_DIR=/Users/kyleklenk/SUMMA-Projects/Summa-Actors export NA_TEST=/home/local/kck540/NA_Summa_Test export SUMMA=/Users/kyleklenk/SUMMA-Projects/Summa-Sundials/summa -docker run -d -it --name SUMMA-Sundials --mount type=bind,source=${PROJECT_DIR},target=/Summa-Actors \ +docker run -d -it --ulimit memlock=32768:32768 --name SUMMA-Sundials --mount type=bind,source=${PROJECT_DIR},target=/Summa-Actors \ --mount type=bind,source=${SUMMA},target=/SUMMA summa-sundials:latest