Porting sketch from Mega to Nano

I have a sketch that works perfectly on Mega, using ports D0 through D13. But when I recompile and upload to Nano, it does not work. Are there any intrinsic differences between the two, in terms of programming, that I should know? (Other than the number of ports, of course.)

The D0 and D1 are the serial port on the Nano. They are used to upload a sketch. The analog pins A0…A5 are also digital pins, perhaps you can use one of those.
D13 on the Nano could have a led, when you use that as input, the led might get in the way.
The Arduino Nano from Ebay uses either the CH340G or a counterfeit FTDI chip.
Perhaps any interrupt is on a different pin.
The 3.3V of the Arduino Nano is not very strong.
And so on…

Could you show your sketch (between code tags).

I do use D13 as input. I will try another port.

I also use D0 and D1 as outputs. Is there something I should do in the program to decouple them from being serial ports?

Between the usb-serial chip (a FTDI or CH340G) and the ATmega328P microcontroller are resistors. RP1B and RP1C in the schematic : Arduino Nano — Arduino Official Store
Because of those resistors, you may override D0 and D1 and use them as outputs. There is no need to do something special.
However, I want to be able to turn on a debug mode and use the serial monitor. Therefor I don't use D0 and D1 (or I use a Arduino Leonardo). The A0...A5 can be used as digital pins because they are normal digital pins, just as D0 to D13. The analog input is an extra, parallel to the digital part of the pin.