@@ -255,11 +255,12 @@ def initial(self):
255255 #### Prepare output file to store info on potential issue for Paddy Rice Water Abstraction
256256 if option .get ('repPaddyRiceDebug' ) is True :
257257 self .debug_paddyrice_filename = os .path .join (settings .output_dir ,f"debug_paddyrice.csv" )
258- if os .path .exists (self .debug_paddyrice_filename ):
259- os .remove (self .debug_paddyrice_filename )
260-
261-
262-
258+ try :
259+ if os .path .exists (self .debug_paddyrice_filename ):
260+ os .remove (self .debug_paddyrice_filename )
261+ except IOError :
262+ print ("Error accessing file {0}" .format (self .debug_paddyrice_filename ))
263+
263264
264265 def dynamic (self ):
265266 """ dynamic part of the water use module
@@ -708,12 +709,15 @@ def dynamic(self):
708709 f"{ self .var .areatotal_withdrawal_LakRes_actual_M3 [idx ]} , { self .var .AreaTotalAvailableWaterFromChannelsM3 [idx ]} , " \
709710 f"{ areatotal_withdrawal_SW_required [idx ]} , { areatotal_withdrawal_SW_required [idx ]- areatotal_PaddyRiceWaterAbstractionFromSurfaceWaterM3 [idx ]} \n "
710711 #print(message)
711- # Open the file in write mode
712- with open (self .debug_paddyrice_filename , 'a' ) as file :
713- if header is not None :
714- file .write (header )
715- # Write the message to the file
716- file .write (message )
712+ try :
713+ # Open the file in write mode
714+ with open (self .debug_paddyrice_filename , 'a' ) as file :
715+ if header is not None :
716+ file .write (header )
717+ # Write the message to the file
718+ file .write (message )
719+ except IOError :
720+ print ("Error accessing file {0} (2)" .format (self .debug_paddyrice_filename ))
717721
718722#from numba import njit
719723#from builtins import max, min
0 commit comments