save serial data to variable?

No, that won't work.
"atoi" expects null-terminated strings.
You could copy from the NMEA string using the "indices" array to a temporary array, terminate that, and then use "atoi".
Maybe terminate in-place? (not sure if the NMEA syntax has sufficient space for that - it probably does.)

[edit]This:

char temp2[] =  linea[j+1];

certainly won't work.[/edit]