We are flying from Split into Madrid and have around 21 days to spend exploring Spain and Portugal. We are not into group tours on a bus and would like to do the train to most of the places if possible. just need some advice on where to go and places to avoid. We like to spend at least 3 nights in most places so we can do day trips in and around the area. I was thinking we should start in San Sebastion and work that way around but the train system is not the best... Any ideas would be greatly appreciated.
I have found the train system in Spain to be very good. San Sebastian is not a major population center and is a remote location, if you have only been looking at trains to/from there . . .
Portugal and Spain are not well connected by train or road, so it's a fairly long, slow overland journey from one to the other. Most people either visit them separately or fly between them. Spain is a fairly large country and very diverse. Where to go and what to see depends greatly on your personal interests and your budget.
Most tourists avoid much of Spain in July - the center (Madrid) and the south are generally very hot and the coast can be very crowded.
It's not that the train system is "bad," it's that it's not as extensive as some other countries. For places the AVE (high speed train) connects, that's definitely the best way to go. For other places, the bus is often better than the train. Buses in Spain are extensive and are much nicer than Greyhound in the US; you get a reserved seat with your ticket.
As Chani says, before you think of seeing Spain and Portugal in one trip, investigate the transit carefully. Flights often work best; there are very limited trains connecting the countries (no high speed trains), and there are some buses. Portugal has airports at Lisbon (center), Porto (north), and Faro (south); Spain has many airports. A quick way to see who flies where from each airport is to look at that airport's Wikipedia page.
Flights and buses do fill in for the sparse train links between the two countries. If you want to rent a car for part of the trip, then the key to keeping costs reasonable is usually to pick up and drop off within the same country, such as pick up in San Sebastian, drive through Portugal and return the car in southern Spain.
P.S. Driving also allows foodies to stop for a fancy, expensive lunch at Mugaritz or Asador Etxebarri, both outside of San Sebastian.
Laura has a good idea with your more extended time available. Drive from Spain to Portugal and back. Great way to see more remote countryside and towns. And great for visting wineries if you are interested in exploring Spanish and Portugese wines. For the big Spanish cities, drop the car and use the train.
As far as more specifics on places and time - that is a wide open question. 3 nights for most big cities is a minimum. Madrid, Barcelna, Sevilla, Lisbon all are worth at least 4 nights and Granada and Porto are 2-3 night stays.
Even with 21 days, you'll find that gets eaten up very quickly. I would recommend focussing on 3-4 cities/regions and really exploring them more at leisure. Portugal will consume at least 6-10 days. San Sebastian and northwestern Spain could be another region. Then certainly a big city like Madrid and its surounding towns could fill 4-5 nights. To really see Andalucia is a 6-10 night stay. Barcelona would be a 4 night visit and there is plenty more to see in Catalunya. There is also northern Spain's Basque region and southeaster Spain around Valencia.
With 3 weeks total, I would think 2 of those would be in Spain with one week for Portugal.
Once you take out time for Madrid and Barcelona, you realistically have to decide between northern Spain or Andalusia for the remaining 6 days.
Day 1 - Start in Madrid (4nts)
Day 2 - Madrid sights - Prado, Royal Palace
Day 3 - Day trip to Toledo
Day 4 - Day trip to Segovia
Day 5 - Train to Sevilla (3nts)
Day 6 - Sevilla sights - Cathedral, Alcazar
Day 7 - Day trip to Cordoba - Mezquita
Day 8 - Train to Ronda (1nt)
Day 9 - Train to Granada (2nts)
Day 10 - Granada sights - Alhambra, Albaicin
Day 11 - Fly to Barcelona (4nts)
Day 12 - Barcelona sights - Sagrada Familia, Passeig de Gracia
Day 13 - Day to trip to Montserrat, or Girona+Figueres
Day 14 - Barcelona sights - Ramblas, Gothic Quarter
Day 15 - Depart Barcelona
I know that much of Australia is pretty hot in the summer, so I expect you know what hot dry weather is like. In Seville, Cordoba, even Madrid and Granada, expect temps in the mid to high 30's. 40 is not unusual in Seville.