<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 load an existing model with external arrays and explicit model_ws
First using free_format which results in open/close
Step1:  Now load the model using base_dir as the model_ws arg
Step2:  Now without free_format which results in old-style control records and unit numbers in the nam file
<ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import flopy
starting_dir = os.getcwd()
base_dir = "base_model_dir"
if not os.path.exists(base_dir):
    os.mkdir(base_dir)
# change to base_dir    
os.chdir(base_dir)    
nlay, nrow, ncol = 1, 1, 10
ml = flopy.modflow.Modflow(modelname="base",external_path="ref")
dis = flopy.modflow.ModflowDis(ml, nrow=1, ncol=10,
                               nlay=nlay, nper=2, perlen=[1,1],
                               steady=[True,True])
bas = flopy.modflow.ModflowBas(ml, ibound=1)
hk = np.zeros((nlay, nrow, ncol))+2.5
lpf = flopy.modflow.ModflowLpf(ml, hk=hk,vka=hk)
well_data = {}
well_data[0] = [0, 0, 9, 0.5]
well_data[1] = [0, 0, 9, 1.0]
wel = flopy.modflow.ModflowWel(ml, stress_period_data=well_data)
ghb_data = {}
ghb_data[0] = [0, 0, 0, 0.5, 1000.0]
ghb = flopy.modflow.ModflowGhb(ml, stress_period_data=ghb_data)
ml.write_input()
# change back 
os.chdir(starting_dir)
Explanation: load an existing model with external arrays and explicit model_ws
First using free_format which results in open/close
End of explanation
ml_loaded = flopy.modflow.Modflow.load("base.nam",model_ws=base_dir)
print ml_loaded.get_package("lpf").hk.array
ml_loaded.change_model_ws("new_dir")
ml_loaded.write_input()
Explanation: Now load the model using base_dir as the model_ws arg
End of explanation
base_dir = "base_model_dir"
if not os.path.exists(base_dir):
    os.mkdir(base_dir)
# change to base_dir    
os.chdir(base_dir)    
nlay, nrow, ncol = 1, 1, 10
ml = flopy.modflow.Modflow(modelname="base",external_path="ref")
ml.array_free_format = False
dis = flopy.modflow.ModflowDis(ml, nrow=1, ncol=10,
                               nlay=nlay, nper=2, perlen=[1,1],
                               steady=[True,True])
bas = flopy.modflow.ModflowBas(ml, ibound=1)
hk = np.zeros((nlay, nrow, ncol))+2.5
lpf = flopy.modflow.ModflowLpf(ml, hk=hk,vka=hk)
well_data = {}
well_data[0] = [0, 0, 9, 0.5]
well_data[1] = [0, 0, 9, 1.0]
wel = flopy.modflow.ModflowWel(ml, stress_period_data=well_data)
ghb_data = {}
ghb_data[0] = [0, 0, 0, 0.5, 1000.0]
ghb = flopy.modflow.ModflowGhb(ml, stress_period_data=ghb_data)
ml.write_input()
# change back 
os.chdir("..")
ml_loaded = flopy.modflow.Modflow.load("base.nam",model_ws=base_dir)
print ml_loaded.get_package("lpf").hk.array
ml_loaded.change_model_ws("new_dir2")
ml_loaded.write_input()
Explanation: Now without free_format which results in old-style control records and unit numbers in the nam file
End of explanation
<END_TASK>