Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Replacement of MOD by MODULO #18

Open
rickyspaceguy opened this issue Oct 19, 2018 · 2 comments
Open

Replacement of MOD by MODULO #18

rickyspaceguy opened this issue Oct 19, 2018 · 2 comments

Comments

@rickyspaceguy
Copy link

This is for gfortran 7.3.0 and relevant source file dealiasing.f90 line 59,72 and 77.

It seems that during compile time gfortran refuses to accept value p2=1. Complaining that for MOD intrinsic fortran 77 function that

 IF (((p1 /= 1).AND.((MOD(order-1,p1-1) == 0))).OR.((p2 /= 1).AND.((MOD(order-1,p2-1) == 0)))) THEN
                                                                               1
Error: Argument ‘P’ of MOD at (1) shall not be zero
../source/main/dealiasing.f90:72:18:

Usage of MODULO (fortran 95 standard) instead of MOD makes it go away.

@alirezaahani4
Copy link

alirezaahani4 commented Oct 8, 2020

Hi,
I added these lines to solve the problem (apparently MODULO has the same syntax as MOD):

!fixing the compilation error with MOD or MODULO at original code IF ( (p2-1) == 0 ) THEN ! MODULO(order-1,p2-1) is not equal to zero LogicalCond = .FALSE. ELSE LogicalCond = .TRUE. END IF

complete modifications:

dealiasing.zip

@deligeer
Copy link

deligeer commented May 4, 2023

LOGICAL :: LogicalCond =.FALSE.
!
! CPU times inlet
IF(iCPUtime.eq.1) then
print*,'entering subroutine dealias'
call CPU_TIME(ti)
ENDIF
!
!fixing the error with MOD or MODULO at original code
IF((p2-1) == 0) THEN
!MODULO(order-1, p2-1) is not equal to zero
LogicalCond =.FALSE.
ELSE
LogicalCond =.TRUE.
END IF
!
! To prevent from multiples FFTs...
!IF (((p1 /= 1).AND.((MOD(order-1,p1-1) == 0))).OR.((p2 /= 1).AND.((MODULO(order-1,p2-1) == 0)))) THEN
IF (((p1 /= 1).AND.((MODULO(order-1,p1-1) == 0))).OR.((p2 /= 1).AND.(LogicalCond))) THEN
!
todealias = space_2_Fourier_big(todealias,type_x,type_y)
ENDIF
!
! analysis of the quantity to dealias on (Nd1,Nd2) modes and keep only (n1,n2) non-zeros
IF (p1 /= 1) THEN
IF ((MOD(order-1,p1-1) == 0)) THEN ! partial dealiasing along x-direction
!
todealias(n1+1:Nd1,1:Nd2) = 0.0_rp
END IF
ENDIF
IF ((n2 /= 1).AND.(p2 /= 1)) THEN
!IF ((MOD(order-1,p2-1) == 0)) THEN! partial dealiasing along y-direction
IF (LogicalCond) THEN! partial dealiasing along y-direction
!
todealias(1:Nd1,n2+1:Nd2) = 0.0_rp
ENDIF
ENDIF
!IF (((p1 /= 1).AND.((MODULO(order-1,p1-1) == 0))).OR.((p2 /= 1).AND.((MOD(order-1,p2-1) == 0)))) THEN
IF (((p1 /= 1).AND.((MODULO(order-1,p1-1) == 0))).OR.((p2 /= 1).AND.(LogicalCond))) THEN
!
todealias = Fourier_2_space_big(todealias,type_x,type_y)
ENDIF
!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants