LHEEA / HOS-NWT

Numerical Wave Tank based on High-Order Spectral method
GNU General Public License v3.0
50 stars 25 forks source link

Replacement of MOD by MODULO #18

Open rickyspaceguy opened 5 years ago

rickyspaceguy commented 5 years ago

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 commented 3 years ago

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 commented 1 year ago

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 !