We develop a software package libEMMI_MGFD for 3D frequency-domain marine controlled-source electromagnetic (CSEM) modelling and inversion. It is the first open-source C program tailored for geometrical multigrid (GMG) CSEM simulation. An volumetric anisotropic averaging scheme has been employed to compute effective medium for modelling over uniform and nonuniform grid. The computing coordinate is aligned with acquisition geometry by rotation with the azimuth and dip angles, facilitating the injection of the source and the extraction of data with arbitrary orientations. Efficient nonlinear optimization is achieved using quasi-Newton scheme assisted with bisection backtracking line search. In constructing the modularized Maxwell solver and evaluating the misfit and gradient for 3D CSEM inversion, the reverse communication technique is the key to the compaction of the software while maintaining the computational performance. A number of numeric tests demonstrate the efficiency of the modelling while preserving the solution accuracy. A 3D marine CSEM inversion example has been examined for resistivity imaging. Program summaryProgram Title: libEMMI_MGFDCPC Library link to program files:https://doi.org/10.17632/mpk7xrd38m.1Developer's repository link:https://github.com/yangpl/libEMMI_MGFDLicensing provisions: GNU General Public License v3.0Programming language: C, ShellSoftware dependencies: MPI [1]Nature of problem: 3D Controlled-source electromagnetic modelling and inversion.Solution method: Frequency-domain modelling on staggered grid; Geometrical multigrid (GMG) method as an iterative solver; Quasi-Newton method for nonlinear minimization; Bisection-based backtracking line search.