As johnpowell said, it’s state-by-state.
California’s is in between open and closed (called “modified” closed, or semi-closed)—- ‘decline to state’ voters can vote for candidates of any party.
Here’s a govt website:
http://www.sos.ca.gov/elections/elections_decline.htm
and googling led me to this: http://ca.lwv.org/lwvc/edfund/elections/e3primary.html, which has some more info
For future reference, the deadline to register or change your name, address, party, etc was January 22 —- 15 days before the primary. You might be stuck on this one but you can change it before the next one. So basically you can re-register for a different party (or unaffiliated) up to ~two weeks before voting, and then switch back after if you want to.