MODULE timeloop_gcm_mod USE genmod USE transfert_mod USE etat0_mod INTEGER,PARAMETER :: euler=1, leapfrog=2, leapfrog_matsuno=3, adam_bashforth=4 CONTAINS SUBROUTINE timeloop USE field_mod USE domain_mod USE write_field USE dimensions USE geometry USE transfert_mod USE metric USE dissip_mod USE ioipsl USE caldyn_gcm_mod USE theta2theta_rhodz_mod USE etat0_mod IMPLICIT NONE TYPE(t_field),POINTER :: f_phis(:) TYPE(t_field),POINTER :: f_theta(:) TYPE(t_field),POINTER :: f_ps(:),f_psm1(:), f_psm2(:) TYPE(t_field),POINTER :: f_u(:),f_um1(:),f_um2(:) TYPE(t_field),POINTER :: f_theta_rhodz(:),f_theta_rhodzm1(:),f_theta_rhodzm2(:) TYPE(t_field),POINTER :: f_dps(:),f_dpsm1(:), f_dpsm2(:) TYPE(t_field),POINTER :: f_du(:),f_dum1(:),f_dum2(:) TYPE(t_field),POINTER :: f_dtheta_rhodz(:),f_dtheta_rhodzm1(:),f_dtheta_rhodzm2(:) REAL(rstd),POINTER :: phis(:) REAL(rstd),POINTER :: ps(:) ,psm1(:), psm2(:) REAL(rstd),POINTER :: u(:,:) , um1(:,:), um2(:,:) REAL(rstd),POINTER :: theta_rhodz(:,:) , theta_rhodzm1(:,:), theta_rhodzm2(:,:) REAL(rstd),POINTER :: dps(:), dpsm1(:), dpsm2(:) REAL(rstd),POINTER :: du(:,:), dum1(:,:), dum2(:,:) REAL(rstd),POINTER :: dtheta_rhodz(:,:),dtheta_rhodzm1(:,:),dtheta_rhodzm2(:,:) REAL(rstd) :: dt INTEGER :: ind INTEGER :: it,i,j,n INTEGER :: scheme INTEGER :: matsuno_period INTEGER :: itaumax dt=90. CALL getin('dt',dt) itaumax=100 CALL getin('itaumax',itaumax) scheme=leapfrog_matsuno CALL getin('scheme',scheme) matsuno_period=5 CALL getin('matsuno_period',matsuno_period) IF (scheme==leapfrog) matsuno_period=itaumax+1 CALL allocate_field(f_phis,field_t,type_real) CALL allocate_field(f_ps,field_t,type_real) CALL allocate_field(f_psm1,field_t,type_real) CALL allocate_field(f_psm2,field_t,type_real) CALL allocate_field(f_dps,field_t,type_real) CALL allocate_field(f_dpsm1,field_t,type_real) CALL allocate_field(f_dpsm2,field_t,type_real) CALL allocate_field(f_u,field_u,type_real,llm) CALL allocate_field(f_um1,field_u,type_real,llm) CALL allocate_field(f_um2,field_u,type_real,llm) CALL allocate_field(f_du,field_u,type_real,llm) CALL allocate_field(f_dum1,field_u,type_real,llm) CALL allocate_field(f_dum2,field_u,type_real,llm) CALL allocate_field(f_theta_rhodz,field_t,type_real,llm) CALL allocate_field(f_theta_rhodzm1,field_t,type_real,llm) CALL allocate_field(f_theta_rhodzm2,field_t,type_real,llm) CALL allocate_field(f_dtheta_rhodz,field_t,type_real,llm) CALL allocate_field(f_dtheta_rhodzm1,field_t,type_real,llm) CALL allocate_field(f_dtheta_rhodzm2,field_t,type_real,llm) CALL allocate_caldyn ! CALL etat0_academic(f_ps,f_phis,f_theta_rhodz,f_u) CALL etat0_jablonowsky06(f_ps,f_phis,f_theta_rhodz,f_u) ! CALL test_etat0_jablonowsky06 DO it=0,itaumax PRINT *,"It No :",It CALL caldyn(f_phis,f_ps,f_theta_rhodz,f_u, f_dps, f_dtheta_rhodz, f_du) IF (scheme==Euler) THEN CALL euler_scheme ELSE IF (scheme==leapfrog) THEN CALL leapfrog_scheme ELSE IF (scheme==leapfrog_matsuno) THEN CALL leapfrog_matsuno_scheme ELSE IF (scheme==adam_bashforth) THEN CALL adam_bashforth_scheme ENDIF ENDDO CONTAINS SUBROUTINE Euler_scheme IMPLICIT NONE INTEGER :: ind DO ind=1,ndomain ps=f_ps(ind) ; u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) dps=f_dps(ind) ; du=f_du(ind) ; dtheta_rhodz=f_dtheta_rhodz(ind) ps(:)=ps(:)+dt*dps(:) u(:,:)=u(:,:)+dt*du(:,:) theta_rhodz(:,:)=theta_rhodz(:,:)+dt*dtheta_rhodz(:,:) ENDDO END SUBROUTINE Euler_scheme SUBROUTINE leapfrog_scheme IMPLICIT NONE INTEGER :: ind DO ind=1,ndomain ps=f_ps(ind) ; u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) psm1=f_psm1(ind) ; um1=f_um1(ind) ; theta_rhodzm1=f_theta_rhodzm1(ind) psm2=f_psm2(ind) ; um2=f_um2(ind) ; theta_rhodzm2=f_theta_rhodzm2(ind) dps=f_dps(ind) ; du=f_du(ind) ; dtheta_rhodz=f_dtheta_rhodz(ind) IF (it==0) THEN psm2(:)=ps(:) ; theta_rhodzm2(:,:)=theta_rhodz(:,:) ; um2(:,:)=u(:,:) ps(:)=ps(:)+dt*dps(:) u(:,:)=u(:,:)+dt*du(:,:) theta_rhodz(:,:)=theta_rhodz(:,:)+dt*dtheta_rhodz(:,:) psm1(:)=ps(:) ; theta_rhodzm1(:,:)=theta_rhodz(:,:) ; um1(:,:)=u(:,:) ELSE ps(:)=psm2(:)+2*dt*dps(:) u(:,:)=um2(:,:)+2*dt*du(:,:) theta_rhodz(:,:)=theta_rhodzm2(:,:)+2*dt*dtheta_rhodz(:,:) psm2(:)=psm1(:) ; theta_rhodzm2(:,:)=theta_rhodzm1(:,:) ; um2(:,:)=um1(:,:) psm1(:)=ps(:) ; theta_rhodzm1(:,:)=theta_rhodz(:,:) ; um1(:,:)=u(:,:) ENDIF ENDDO END SUBROUTINE leapfrog_scheme SUBROUTINE leapfrog_matsuno_scheme IMPLICIT NONE INTEGER :: ind DO ind=1,ndomain ps=f_ps(ind) ; u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) psm1=f_psm1(ind) ; um1=f_um1(ind) ; theta_rhodzm1=f_theta_rhodzm1(ind) psm2=f_psm2(ind) ; um2=f_um2(ind) ; theta_rhodzm2=f_theta_rhodzm2(ind) dps=f_dps(ind) ; du=f_du(ind) ; dtheta_rhodz=f_dtheta_rhodz(ind) IF (MOD(it,matsuno_period+1)==0) THEN psm1(:)=ps(:) ; um1(:,:)=u(:,:) ; theta_rhodzm1(:,:)=theta_rhodz(:,:) ps(:)=psm1(:)+dt*dps(:) u(:,:)=um1(:,:)+dt*du(:,:) theta_rhodz(:,:)=theta_rhodzm1(:,:)+dt*dtheta_rhodz(:,:) ELSE IF (MOD(it,matsuno_period+1)==1) THEN ps(:)=psm1(:)+dt*dps(:) u(:,:)=um1(:,:)+dt*du(:,:) theta_rhodz(:,:)=theta_rhodzm1(:,:)+dt*dtheta_rhodz(:,:) psm2(:)=psm1(:) ; theta_rhodzm2(:,:)=theta_rhodzm1(:,:) ; um2(:,:)=um1(:,:) psm1(:)=ps(:) ; theta_rhodzm1(:,:)=theta_rhodz(:,:) ; um1(:,:)=u(:,:) ELSE ps(:)=psm2(:)+2*dt*dps(:) u(:,:)=um2(:,:)+2*dt*du(:,:) theta_rhodz(:,:)=theta_rhodzm2(:,:)+2*dt*dtheta_rhodz(:,:) psm2(:)=psm1(:) ; theta_rhodzm2(:,:)=theta_rhodzm1(:,:) ; um2(:,:)=um1(:,:) psm1(:)=ps(:) ; theta_rhodzm1(:,:)=theta_rhodz(:,:) ; um1(:,:)=u(:,:) ENDIF ENDDO END SUBROUTINE leapfrog_matsuno_scheme SUBROUTINE adam_bashforth_scheme IMPLICIT NONE INTEGER :: ind DO ind=1,ndomain ps=f_ps(ind) ; u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) dps=f_dps(ind) ; du=f_du(ind) ; dtheta_rhodz=f_dtheta_rhodz(ind) dpsm1=f_dpsm1(ind) ; dum1=f_dum1(ind) ; dtheta_rhodzm1=f_dtheta_rhodzm1(ind) dpsm2=f_dpsm2(ind) ; dum2=f_dum2(ind) ; dtheta_rhodzm2=f_dtheta_rhodzm2(ind) IF (it==0) THEN dpsm1(:)=dps(:) ; dum1(:,:)=du(:,:) ; dtheta_rhodzm1(:,:)=dtheta_rhodz(:,:) dpsm2(:)=dpsm1(:) ; dum2(:,:)=dum1(:,:) ; dtheta_rhodzm2(:,:)=dtheta_rhodzm1(:,:) ENDIF ps(:)=ps(:)+dt*(23*dps(:)-16*dpsm1(:)+5*dpsm2(:))/12 u(:,:)=u(:,:)+dt*(23*du(:,:)-16*dum1(:,:)+5*dum2(:,:))/12 theta_rhodz(:,:)=theta_rhodz(:,:)+dt*(23*dtheta_rhodz(:,:)-16*dtheta_rhodzm1(:,:)+5*dtheta_rhodzm2(:,:))/12 dpsm2(:)=dpsm1(:) ; dum2(:,:)=dum1(:,:) ; dtheta_rhodzm2(:,:)=dtheta_rhodzm1(:,:) dpsm1(:)=dps(:) ; dum1(:,:)=du(:,:) ; dtheta_rhodzm1(:,:)=dtheta_rhodz(:,:) ENDDO END SUBROUTINE adam_bashforth_scheme END SUBROUTINE timeloop END MODULE timeloop_gcm_mod