But you define and set D=0 in the function as a local variable inside the function modeleth so nothing outside prior to that matters, global or not.
And, once you declare D as global in the script |corridaModelethtarea then it's as global as it's going to get--there's on point in repeating the same instruction.
If you want to use global D to set other parameters inside the function function modeleth that's certainly one way to do so, but you must then use that copy inside the function as well -- declare it global in the function as well and do not initialize it there--only in the other script.
Alternatively, and somewhat cleaner in terms of avoiding global variables, see the third example in the documentation for ode23 that show how to pass additional parameters to the solved function via an anonymous function that uses the additional argument. NB: to have the function utilize the update variables, the anonymous function has to be created after the new value of D is defined; that value is embedded in the anonymous function itself and not read/associated from the variable when called.