Skip to content
Snippets Groups Projects
Commit 784baff1 authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann
Browse files

Checkpoint loading are done on output file now, bug in write 5D corrected

parent 8e16d3b4
No related branches found
No related tags found
No related merge requests found
......@@ -382,7 +382,12 @@ SUBROUTINE diagnose_5d
ELSE
CALL putarr(fidres, dset_name, field(ips_e:ipe_e,ijs_e:ije_e,ikrs:ikre,ikzs:ikze), pardim=3)
ENDIF
CALL attach(fidres, dset_name, "time", time)
CALL attach(fidres, dset_name, 'cstep', cstep)
CALL attach(fidres, dset_name, 'time', time)
CALL attach(fidres, dset_name, 'jobnum', jobnum)
CALL attach(fidres, dset_name, 'dt', dt)
CALL attach(fidres, dset_name, 'iframe2d', iframe2d)
CALL attach(fidres, dset_name, 'iframe5d', iframe5d)
END SUBROUTINE write_field5d_e
......@@ -403,8 +408,13 @@ SUBROUTINE diagnose_5d
ELSE
CALL putarr(fidres, dset_name, field(ips_i:ipe_i,ijs_i:ije_i,ikrs:ikre,ikzs:ikze), pardim=3)
ENDIF
CALL attach(fidres, dset_name, "time", time)
CALL attach(fidres, dset_name, 'cstep', cstep)
CALL attach(fidres, dset_name, 'time', time)
CALL attach(fidres, dset_name, 'jobnum', jobnum)
CALL attach(fidres, dset_name, 'dt', dt)
CALL attach(fidres, dset_name, 'iframe2d', iframe2d)
CALL attach(fidres, dset_name, 'iframe5d', iframe5d)
END SUBROUTINE write_field5d_i
END SUBROUTINE diagnose_5d
......
......@@ -22,14 +22,14 @@ SUBROUTINE inital
!!!!!! Set the moments arrays Nepj, Nipj !!!!!!
! WRITE(*,*) 'Init moments'
IF ( RESTART ) THEN
CALL load_cp
CALL load_output
! CALL load_cp
ELSE
CALL init_moments
!!!!!! Set phi !!!!!!
IF (my_id .EQ. 0) WRITE(*,*) 'Init phi'
CALL poisson
ENDIF
IF (my_id .EQ. 0) WRITE(*,*) 'Init phi'
CALL poisson
!!!!!! Set Sepj, Sipj and dnjs coeff table !!!!!!
IF ( NON_LIN ) THEN;
......@@ -46,10 +46,6 @@ SUBROUTINE inital
IF (my_id .EQ. 0) WRITE(*,*) '..done'
ENDIF
! IF (my_id .EQ. 0) WRITE(*,*) 'Set closure model..'
! CALL apply_closure_model
! IF (my_id .EQ. 0) WRITE(*,*) '..done'
END SUBROUTINE inital
!******************************************************************************!
......@@ -138,6 +134,98 @@ SUBROUTINE init_moments
END SUBROUTINE init_moments
!******************************************************************************!
!******************************************************************************!
!!!!!!! Load moments from a previous output file
!******************************************************************************!
SUBROUTINE load_output
USE basic
USE futils, ONLY: openf, closef, getarr, getatt, isgroup, isdataset
USE grid
USE fields
USE diagnostics_par
USE time_integration
IMPLICIT NONE
INTEGER :: rank, sz_, n_
INTEGER :: dims(1) = (/0/)
CHARACTER(LEN=50) :: dset_name
INTEGER :: pmaxe_cp, jmaxe_cp, pmaxi_cp, jmaxi_cp
COMPLEX(dp), DIMENSION(:,:,:,:), ALLOCATABLE :: moments_e_cp
COMPLEX(dp), DIMENSION(:,:,:,:), ALLOCATABLE :: moments_i_cp
! Checkpoint filename
WRITE(rstfile,'(a,a1,i2.2,a3)') TRIM(resfile0),'_',job2load,'.h5'
IF (my_id .EQ. 0) WRITE(*,'(3x,a)') "Resume from ", rstfile
! Open file
CALL openf(rstfile, fidrst,mpicomm=MPI_COMM_WORLD)
! Get the checkpoint moments degrees to allocate memory
CALL getatt(fidrst,"/data/input/" , "pmaxe", pmaxe_cp)
CALL getatt(fidrst,"/data/input/" , "jmaxe", jmaxe_cp)
CALL getatt(fidrst,"/data/input/" , "pmaxi", pmaxi_cp)
CALL getatt(fidrst,"/data/input/" , "jmaxi", jmaxi_cp)
IF (my_id .EQ. 0) WRITE(*,*) "Pe_cp = ", pmaxe_cp
IF (my_id .EQ. 0) WRITE(*,*) "Je_cp = ", jmaxe_cp
! Allocate the required size to load checkpoints moments
CALL allocate_array(moments_e_cp, 1,pmaxe_cp+1, 1,jmaxe_cp+1, ikrs,ikre, ikzs,ikze)
CALL allocate_array(moments_i_cp, 1,pmaxi_cp+1, 1,jmaxi_cp+1, ikrs,ikre, ikzs,ikze)
! Find the last results of the checkpoint file by iteration
n_ = 1
WRITE(dset_name, "(A, '/', i6.6)") "/data/var5d/moments_e", n_ ! start with moments_e/000001
DO WHILE (isdataset(fidrst, dset_name)) ! If n_ is not a file we stop the loop
n_ = n_ + 1
WRITE(dset_name, "(A, '/', i6.6)") "/data/var5d/moments_e", n_ ! updtate file number
ENDDO
n_ = n_ - 1 ! n_ is not a file so take the previous one n_-1
! Read state of system from checkpoint file
WRITE(dset_name, "(A, '/', i6.6)") "/data/var5d/moments_e", n_
CALL getarr(fidrst, dset_name, moments_e_cp(1:pmaxe_cp+1, 1:jmaxe_cp+1, ikrs:ikre, ikzs:ikze),pardim=3)
WRITE(dset_name, "(A, '/', i6.6)") "/data/var5d/moments_i", n_
CALL getarr(fidrst, dset_name, moments_i_cp(1:pmaxi_cp+1, 1:jmaxi_cp+1, ikrs:ikre, ikzs:ikze),pardim=3)
! Initialize simulation moments array with checkpoints ones
! (they may have a larger number of polynomials, set to 0 at the begining)
moments_e = 0._dp; moments_i = 0._dp
DO ip=1,pmaxe_cp+1
DO ij=1,jmaxe_cp+1
DO ikr=ikrs,ikre
DO ikz=ikzs,ikze
moments_e(ip,ij,ikr,ikz,:) = moments_e_cp(ip,ij,ikr,ikz)
ENDDO
ENDDO
ENDDO
ENDDO
DO ip=1,pmaxi_cp+1
DO ij=1,jmaxi_cp+1
DO ikr=ikrs,ikre
DO ikz=ikzs,ikze
moments_i(ip,ij,ikr,ikz,:) = moments_i_cp(ip,ij,ikr,ikz)
ENDDO
ENDDO
ENDDO
ENDDO
! Deallocate checkpoint arrays
DEALLOCATE(moments_e_cp)
DEALLOCATE(moments_i_cp)
! Read time dependent attributes to continue simulation
CALL getatt(fidrst, dset_name, 'cstep', cstep)
CALL getatt(fidrst, dset_name, 'time', time)
CALL getatt(fidrst, dset_name, 'jobnum', jobnum)
jobnum = jobnum+1
CALL getatt(fidrst, dset_name, 'iframe2d',iframe2d)
CALL getatt(fidrst, dset_name, 'iframe5d',iframe5d)
iframe2d = iframe2d-1; iframe5d = iframe5d-1
CALL closef(fidrst)
IF (my_id .EQ. 0) WRITE(*,'(3x,a)') "Reading from restart file "//TRIM(rstfile)//" completed!"
END SUBROUTINE load_output
!******************************************************************************!
!******************************************************************************!
!!!!!!! Load moments from a previous save
!******************************************************************************!
......@@ -232,6 +320,7 @@ SUBROUTINE load_cp
END SUBROUTINE load_cp
!******************************************************************************!
!******************************************************************************!
!!!!!!! Build the Laguerre-Laguerre coupling coefficient table for nonlin
!******************************************************************************!
......@@ -287,7 +376,7 @@ SUBROUTINE evaluate_kernels
sigmae2_taue_o2 = sigma_e**2 * tau_e/2._dp ! factor of the Kernel argument
factj = 1.0 ! Start of the recursive factorial
DO ij = ijs_e, ije_e
DO ij = 1, jmaxe+1
j_int = jarray_e(ij)
j_dp = REAL(j_int,dp) ! REAL of degree
......@@ -310,12 +399,21 @@ SUBROUTINE evaluate_kernels
ENDDO
ENDDO
ENDDO
! Kernels closure
DO ikr = ikrs,ikre
kr = krarray(ikr)
DO ikz = ikzs,ikze
kz = kzarray(ikz)
be_2 = (kr**2 + kz**2) * sigmae2_taue_o2
kernel_e(ijeg_e,ikr,ikz) = be_2/(real(ijeg_e,dp))*kernel_e(ije_e,ikr,ikz)
ENDDO
ENDDO
!!!!! Ion kernels !!!!!
sigmai2_taui_o2 = sigma_i**2 * tau_i/2._dp ! (b_a/2)^2 = (kperp sqrt(2 tau_a) sigma_a/2)^2
factj = 1.0 ! Start of the recursive factorial
DO ij = ijs_i, ije_i
DO ij = 1, jmaxi+1
j_int = jarray_e(ij)
j_dp = REAL(j_int,dp) ! REAL of degree
......@@ -338,6 +436,14 @@ SUBROUTINE evaluate_kernels
ENDDO
ENDDO
ENDDO
! Kernels closure
DO ikr = ikrs,ikre
kr = krarray(ikr)
DO ikz = ikzs,ikze
kz = kzarray(ikz)
bi_2 = (kr**2 + kz**2) * sigmai2_taui_o2
kernel_i(ijeg_i,ikr,ikz) = bi_2/(real(ijeg_i,dp))*kernel_e(ije_i,ikr,ikz)
ENDDO
ENDDO
END SUBROUTINE evaluate_kernels
!******************************************************************************!
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment