subroutine DEALLOCATE_ARRAYS_NormalCirculation()    !  is called in module FluidFlowMain
    USE MudSystemVARIABLES
use SimulationVariables !@@@
    implicit none


if(allocated(data%State%MudSystem%Xstart_PipeSection)) deallocate(data%State%MudSystem%Xstart_PipeSection)  
if(allocated(data%State%MudSystem%Xend_PipeSection)) deallocate(data%State%MudSystem%Xend_PipeSection)        
if(allocated(data%State%MudSystem%PipeSection_VolumeCapacity)) deallocate(data%State%MudSystem%PipeSection_VolumeCapacity)        
if(allocated(data%State%MudSystem%Area_PipeSectionFt)) deallocate(data%State%MudSystem%Area_PipeSectionFt)     
if(allocated(data%State%MudSystem%OD_PipeSectionInch)) deallocate(data%State%MudSystem%OD_PipeSectionInch)        
if(allocated(data%State%MudSystem%ID_PipeSectionInch)) deallocate(data%State%MudSystem%ID_PipeSectionInch)   
if(allocated(data%State%MudSystem%Xstart_OpSection)) deallocate(data%State%MudSystem%Xstart_OpSection)  
if(allocated(data%State%MudSystem%Xend_OpSection)) deallocate(data%State%MudSystem%Xend_OpSection)        
if(allocated(data%State%MudSystem%Area_OpSectionFt)) deallocate(data%State%MudSystem%Area_OpSectionFt)        
if(allocated(data%State%MudSystem%OD_OpSectionInch)) deallocate(data%State%MudSystem%OD_OpSectionInch)        
if(allocated(data%State%MudSystem%ID_OpSectionInch)) deallocate(data%State%MudSystem%ID_OpSectionInch)        
if(allocated(data%State%MudSystem%OpSection_VolumeCapacity)) deallocate(data%State%MudSystem%OpSection_VolumeCapacity)  
if(allocated(data%State%MudSystem%GeoTypeOp)) deallocate(data%State%MudSystem%GeoTypeOp)        
if(allocated(data%State%MudSystem%GeoType)) deallocate(data%State%MudSystem%GeoType)        


            call data%State%MudSystem%Hz_MudDischarged_Volume%Empty()
            call data%State%MudSystem%Hz_Mud_Backhead_X%Empty()
            call data%State%MudSystem%Hz_Mud_Backhead_section%Empty()
            call data%State%MudSystem%Hz_Mud_Forehead_X%Empty()
            call data%State%MudSystem%Hz_Mud_Forehead_section%Empty()
            call data%State%MudSystem%Hz_Density%Empty()
            call data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Empty()
            call data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Empty() 
            call data%State%MudSystem%Hz_MudOrKick%Empty()                                        
            
                                
            call data%State%MudSystem%St_MudDischarged_Volume%Empty()
            call data%State%MudSystem%St_Mud_Backhead_X%Empty()
            call data%State%MudSystem%St_Mud_Backhead_section%Empty()
            call data%State%MudSystem%St_Mud_Forehead_X%Empty()
            call data%State%MudSystem%St_Mud_Forehead_section%Empty()
            call data%State%MudSystem%St_Density%Empty()
            call data%State%MudSystem%St_RemainedVolume_in_LastSection%Empty()
            call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Empty()  
            call data%State%MudSystem%St_MudOrKick%Empty()                                        
            
                
            call data%State%MudSystem%Ann_MudDischarged_Volume%Empty()
            call data%State%MudSystem%Ann_Mud_Backhead_X%Empty()
            call data%State%MudSystem%Ann_Mud_Backhead_section%Empty()
            call data%State%MudSystem%Ann_Mud_Forehead_X%Empty()
            call data%State%MudSystem%Ann_Mud_Forehead_section%Empty()
            call data%State%MudSystem%Ann_Density%Empty()
            call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Empty()
            call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Empty()
            call data%State%MudSystem%Ann_MudOrKick%Empty() 
            call data%State%MudSystem%Ann_CuttingMud%Empty() 
            
            
            call data%State%MudSystem%Op_MudDischarged_Volume%Empty()
            call data%State%MudSystem%Op_Mud_Backhead_X%Empty()
            call data%State%MudSystem%Op_Mud_Backhead_section%Empty()
            call data%State%MudSystem%Op_Mud_Forehead_X%Empty()
            call data%State%MudSystem%Op_Mud_Forehead_section%Empty()
            call data%State%MudSystem%Op_Density%Empty()
            call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Empty()
            call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Empty()
            call data%State%MudSystem%Op_MudOrKick%Empty()                                        
            

            call data%State%MudSystem%ChokeLine_MudDischarged_Volume%Empty()
            call data%State%MudSystem%ChokeLine_Mud_Backhead_X%Empty()
            call data%State%MudSystem%ChokeLine_Mud_Backhead_section%Empty()
            call data%State%MudSystem%ChokeLine_Mud_Forehead_X%Empty()
            call data%State%MudSystem%ChokeLine_Mud_Forehead_section%Empty()
            call data%State%MudSystem%ChokeLine_Density%Empty()
            call data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%Empty()
            call data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Empty()
            call data%State%MudSystem%ChokeLine_MudOrKick%Empty()  
            
            
        call data%State%MudSystem%Xend_MudElement%Empty()
        call data%State%MudSystem%Xstart_MudElement%Empty()
        call data%State%MudSystem%TVDend_MudElement%Empty()
        call data%State%MudSystem%TVDstart_MudElement%Empty()
        call data%State%MudSystem%Density_MudElement%Empty()
        call data%State%MudSystem%MudGeoType%Empty()
        call data%State%MudSystem%PipeID_MudElement%Empty()
        call data%State%MudSystem%PipeOD_MudElement%Empty()
        call data%State%MudSystem%MudType_MudElement%Empty()            
            
        call data%State%MudSystem%Xend_OpMudElement%Empty()
        call data%State%MudSystem%Xstart_OpMudElement%Empty()
        call data%State%MudSystem%TVDend_OpMudElement%Empty()
        call data%State%MudSystem%TVDstart_OpMudElement%Empty()
        call data%State%MudSystem%Density_OpMudElement%Empty()
        call data%State%MudSystem%PipeID_OpMudElement%Empty()
        call data%State%MudSystem%PipeOD_OpMudElement%Empty()
        call data%State%MudSystem%MudTypeOp_MudElement%Empty()            
    end subroutine
    
    
    
subroutine RemoveAnnulusMudArrays(ilocal)
    USE MudSystemVARIABLES
use SimulationVariables !@@@
    implicit none
    
    INTEGER :: ilocal
    
    
                    call data%State%MudSystem%Ann_MudDischarged_Volume%Remove (ilocal)
                    call data%State%MudSystem%Ann_Mud_Backhead_X%Remove (ilocal)
                    call data%State%MudSystem%Ann_Mud_Backhead_section%Remove (ilocal)
                    call data%State%MudSystem%Ann_Mud_Forehead_X%Remove (ilocal)
                    call data%State%MudSystem%Ann_Mud_Forehead_section%Remove (ilocal)
                    call data%State%MudSystem%Ann_Density%Remove (ilocal)
                    call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Remove (ilocal)
                    call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (ilocal)
                    call data%State%MudSystem%Ann_MudOrKick%Remove (ilocal)
                    call data%State%MudSystem%Ann_CuttingMud%Remove (ilocal)     
    
    
    
    end subroutine
    
    
subroutine RemoveStringMudArrays(ilocal)
    USE MudSystemVARIABLES
use SimulationVariables !@@@
    implicit none
    
    INTEGER :: ilocal
    
    
                    call data%State%MudSystem%St_MudDischarged_Volume%Remove (ilocal)
                    call data%State%MudSystem%St_Mud_Backhead_X%Remove (ilocal)
                    call data%State%MudSystem%St_Mud_Backhead_section%Remove (ilocal)
                    call data%State%MudSystem%St_Mud_Forehead_X%Remove (ilocal)
                    call data%State%MudSystem%St_Mud_Forehead_section%Remove (ilocal)
                    call data%State%MudSystem%St_Density%Remove (ilocal)
                    call data%State%MudSystem%St_RemainedVolume_in_LastSection%Remove (ilocal)
                    call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Remove (ilocal)
                    call data%State%MudSystem%St_MudOrKick%Remove (ilocal)    
    
    
    
    end subroutine    
    
    
subroutine RemoveOpMudArrays(ilocal)
    USE MudSystemVARIABLES
use SimulationVariables !@@@
    implicit none
    
    INTEGER :: ilocal
    
    
                    call data%State%MudSystem%Op_MudDischarged_Volume%Remove (ilocal)
                    call data%State%MudSystem%Op_Mud_Backhead_X%Remove (ilocal)
                    call data%State%MudSystem%Op_Mud_Backhead_section%Remove (ilocal)
                    call data%State%MudSystem%Op_Mud_Forehead_X%Remove (ilocal)
                    call data%State%MudSystem%Op_Mud_Forehead_section%Remove (ilocal)
                    call data%State%MudSystem%Op_Density%Remove (ilocal)
                    call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Remove (ilocal)
                    call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (ilocal)
                    call data%State%MudSystem%Op_MudOrKick%Remove (ilocal)    
    
    
    
    end subroutine      
    
subroutine RemoveHzMudArrays(ilocal)
    USE MudSystemVARIABLES
use SimulationVariables !@@@
    implicit none
    
    INTEGER :: ilocal
    
    
                    call data%State%MudSystem%Hz_MudDischarged_Volume%Remove (ilocal)
                    call data%State%MudSystem%Hz_Mud_Backhead_X%Remove (ilocal)
                    call data%State%MudSystem%Hz_Mud_Backhead_section%Remove (ilocal)
                    call data%State%MudSystem%Hz_Mud_Forehead_X%Remove (ilocal)
                    call data%State%MudSystem%Hz_Mud_Forehead_section%Remove (ilocal)
                    call data%State%MudSystem%Hz_Density%Remove (ilocal)
                    call data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Remove (ilocal)
                    call data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Remove (ilocal)
                    call data%State%MudSystem%Hz_MudOrKick%Remove (ilocal)    
    
    
    
     end subroutine      
   