Skip to content

Save/Resume changes to accommodate routing only simulations #113

@mee067

Description

@mee067

This was initially raised by @MazdaKompanizare when he was trying to use initial conditions from a normal simulation (LSS + Routing) for a routing only simulation (runroute nolss) or resuming a routing-only simulation from another routing-only simulation. Reading initial conditions for the LSS made issues in such a case and the system wanted to save them at the end (or at intervals using autosave). To overcome these issue and to economize file sizes (in case LSS is not running), I made those changes to r1860_ME_ZT to condition reading and writing on which components are active. I saw these were not carried over in 1.5.1.

In resumerun_save.f90

        if (index(resume_options%save%bin, '+STASONLY') == 0 .and. index(resume_options%save%bin, '+CLASSPROG') == 0) then
!<< ME Nov 3, 2023 - Added conditions based on whether LSS and/or Routing are active or not
            if (svs_mesh%PROCESS_ACTIVE .or. RUNCLASS36_flgs%PROCESS_ACTIVE) then
                call save_init_prog_variables_class(fls, shd)
                call runsvs_mesh_save_states_seq(fls, shd)
                call bflm_resume_save(fls, shd)
            end if
            if (WF_RTE_flgs%PROCESS_ACTIVE .or. rteflg%PROCESS_ACTIVE) then
                call WF_ROUTE_resume_save(fls, shd)
                call run_rte_resume_save(fls, shd)
            end if
            call run_save_basin_output_resume_save(fls, shd)
            call stats_state_save(fls)
!>>>>>zone-based storage
            if (RESERVOIRFLAG == 2) then
                iun = 100
                if (resume_options%save%freq /= FREQ_NUL .and. resume_options%save%freq /= FREQ_NOW) then
                    open(iun, file = 'zone_storage_states.' // trim(adjustl(line)) // '.txt', action = 'write', status = 'replace')
                else
                    open(iun, file = 'zone_storage_states.txt', action = 'write', status = 'replace')
                end if
                write(iun, *) (resrvs%rsvr(i)%stoSIM(1), i = 1, resrvs%nreserv), '# Intstor1(1:NRESV)'
                write(iun, *) (resrvs%rsvr(i)%flowSIM(1), i = 1, resrvs%nreserv), '# flowO1(1:NRESV)'
                close(iun)
            end if
!<<<<<zone-based storage
        else if (index(resume_options%save%bin, '+CLASSPROG') == 0) then
!<< ME Nov 3, 2023 - Added conditions based on whether LSS and/or Routing are active or not		
            if (svs_mesh%PROCESS_ACTIVE .or. RUNCLASS36_flgs%PROCESS_ACTIVE) then
                call save_init_prog_variables_class(fls, shd)
                call runsvs_mesh_save_states_seq(fls, shd)
                call bflm_resume_save(fls, shd)
            end if
            if (WF_RTE_flgs%PROCESS_ACTIVE .or. rteflg%PROCESS_ACTIVE) then
                call WF_ROUTE_resume_save(fls, shd)
                call run_rte_resume_save(fls, shd)
            end if

and in **resumerun_read.f90**

            if (index(resume_options%resume%bin, '+STASONLY') == 0 .and. index(resume_options%resume%bin, '+CLASSPROG') == 0) then
!<< ME Nov 3, 2023 - Added conditions based on whether LSS and/or Routing are active or not
                if (svs_mesh%PROCESS_ACTIVE .or. RUNCLASS36_flgs%PROCESS_ACTIVE) then
                    call read_init_prog_variables_class(fls, shd)				
                    call runsvs_mesh_resume_states_seq(fls, shd, resume_ts = .true.)
                    call bflm_resume_read(fls, shd)
                end if
                if (WF_RTE_flgs%PROCESS_ACTIVE .or. rteflg%PROCESS_ACTIVE) then
                    call WF_ROUTE_resume_read(fls, shd)
                    call run_rte_resume_read(fls, shd)
                end if
                call run_save_basin_output_resume_read(fls, shd)
                call stats_state_resume(fls)
!>>>>>zone-based storage
                if (RESERVOIRFLAG == 2) then
                    iun = 100
                    if (resume_options%resume%state == FLAG_AUTO) then
                        open(iun, file = 'zone_storage_states.' // trim(adjustl(line)) // '.txt', action = 'read', status = 'old')
                    else
                        open(iun, file = 'zone_storage_states.txt', action = 'read', status = 'old')
                    end if
                    read(iun, *) (resrvs%rsvr(i)%stoSIM(1), i = 1, resrvs%nreserv)
                    read(iun, *) (resrvs%rsvr(i)%flowSIM(1), i = 1, resrvs%nreserv)
                    close(iun)
                end if
!<<<<<zone-based storage
            else if (index(resume_options%resume%bin, '+CLASSPROG') == 0) then
!<< ME Nov 3, 2023 - Added conditions based on whether LSS and/or Routing are active or not
                if (svs_mesh%PROCESS_ACTIVE .or. RUNCLASS36_flgs%PROCESS_ACTIVE) then
                    call read_init_prog_variables_class(fls, shd)
                    call runsvs_mesh_resume_states_seq(fls, shd, resume_ts = .false.)
                    call bflm_resume_read(fls, shd)
                end if
                if (WF_RTE_flgs%PROCESS_ACTIVE .or. rteflg%PROCESS_ACTIVE) then
                    call WF_ROUTE_resume_read_nots(fls, shd)
                    call run_rte_resume_read_nots(fls, shd)
                end if

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions