module principal_cshift_m IMPLICIT NONE CONTAINS SUBROUTINE principal_cshift(is2, xlon, xprimm) ! Add or subtract 2 pi so that xlon is near [-pi, pi], then cshift ! so that xlon is in ascending order. Make the same cshift on ! xprimm. USE lmdz_physical_constants, ONLY: twopi USE serre_mod, ONLY: clon INCLUDE "dimensions.h" ! for iim INTEGER, INTENT(IN):: is2 REAL, INTENT(INOUT):: xlon(:), xprimm(:) ! (iim + 1) !----------------------------------------------------- IF (is2 /= 0) THEN IF (clon <= 0.) THEN IF (is2 /= 1) THEN xlon(:is2 - 1) = xlon(:is2 - 1) + twopi xlon(:iim) = cshift(xlon(:iim), shift = is2 - 1) xprimm(:iim) = cshift(xprimm(:iim), shift = is2 - 1) END IF else xlon(is2 + 1:iim) = xlon(is2 + 1:iim) - twopi xlon(:iim) = cshift(xlon(:iim), shift = is2) xprimm(:iim) = cshift(xprimm(:iim), shift = is2) end IF end if xlon(iim + 1) = xlon(1) + twopi xprimm(iim + 1) = xprimm(1) END SUBROUTINE principal_cshift END MODULE principal_cshift_m