Having a program behavior change with the addition or removal of a WRITE statement is one of the most difficult problems to debug. The bottom line is that there is something wrong with the code. Adding/deleting a WRITE statement changes the way that memory is organized in the executable. One way, it happens to work, but for the wrong reasons. The other way, the program crashes.
Likely causes are an array out of bounds or a mismatch in subroutine arguments that just doesn't get caught. Another possibility is a compiler optimization error.
Compile optimization problems do exist. For example, on STAMPEDE (TACC computer), using the default "ifort", the compile of file "module_bl_temf.f90" will never finish at opt 3. It must be compiled at opt 2.
You might try doing a "clean -a", then a "configure -d". The "-d" sets up a debug "configure.wrf" file. If that doesn't help, use "-D" instead of "-d", which checks more. Look for the work "debug" in "configure" to see more specifics.
Kevin W. Thomas
Center for Analysis and Prediction of Storms
University of Oklahoma