The subroutine nextyear_forcing is broken. If the path to the file is exactly 80 characters long, or is passed as trim(cfile) it won't have any blank characters and goodness knows what will be returned. I suggest using INDEX(fname,'.nc',back=.true.) to find the location of the '.nc' suffix. If 0 (i.e. no suffix '.nc') is returned then an error should be returned. That could be checked earlier on though.
The subroutine nextyear_forcing is broken. If the path to the file is exactly 80 characters long, or is passed as trim(cfile) it won't have any blank characters and goodness knows what will be returned. I suggest using INDEX(fname,'.nc',back=.true.) to find the location of the '.nc' suffix. If 0 (i.e. no suffix '.nc') is returned then an error should be returned. That could be checked earlier on though.