Two-dimensional Josephson junctions arrays in the presence of a magnetic field