Cotterell, William, Judge Advocate in Portugal