A code PNCMC (Program for Natural Circulation under Motion Conditions) has been developed for natural circulation simulation of marine reactors. The code is based on one-dimensional two-fluid model in noninertial frame of reference. The body force term in the momentum equation is considered as a time dependent function, which consists of gravity and inertial force induced by three-dimensional ship motion. Staggered mesh, finite volume method, semi-implicit first order upwind scheme and Successive Over Relaxation (SOR) method are used to discretize and solve two-phase mass, momentum and energy equations. Single-phase natural circulation experiments under rolling condition performed in Institute of nuclear and new energy technology of Tsinghua University and two-phase natural circulation experiments under rolling condition performed by Tan and colleagues are used to validate PNCMC. The validation results indicate that PNCMC is capable to investigate the single-phase and two-phase natural circulation under rolling motion.