!Copyright (c) 2013 by tdem.org under guide of Xiu Li(lixiu@chd.edu.cn) !written by Huaifeng Sun(sunhuaifeng@gmail.com) and Xushan Lu(luxushan@gmail.com) !Code distribution @ tdem.org or sunhuaifeng.com !function description !this subroutine is used to allocate dynamic memory to the selected array. !all allocatable variables which can be allocated automaticly after getting !the input parameters file are allocated here. !2016-10-30 by Huaifeng Sun SUBROUTINE ALLOCATEMEMORY USE CONSTANTPARAMETERS USE ELECTROMAGNETIC_VARIABLES USE RES_MODEL_PARAMETER USE TIME_PARAMETER USE PML_PARAMETER IMPLICIT NONE INTEGER ERR WRITE(*,*)'Allocating memory... ...' !>Allocate the arrays in ELECTROMAGNETIC_VARIABLES !! Allocate electric field components EX, EY, EZ !! Allocate magnetic field components HX, HY, HZ ALLOCATE(EX(NX,NYB,NZB), EY(NXB,NY,NZB), EZ(NXB,NYB,NZ), STAT=ERR) ALLOCATE(HX(NXB,NY,0:NZ), HY(NX,NYB,0:NZ), HZ(NX,NY,NZB), STAT=ERR) !>Allocate the array in RES_MODEL_PARAMETER !! Allocate conductivity arrays ALLOCATE(CCSIG(NX,NY,NZ)) ALLOCATE(CCSIGX(NX,NYB,NZB), CCSIGY(NXB,NY,NZB), CCSIGZ(NXB,NYB,NZ)) ALLOCATE(LenRatio_CCSIGX(NX,NYB,NZB), LenRatio_CCSIGY(NXB,NY,NZB), LenRatio_CCSIGZ(NXB,NYB,NZ)) allocate(Coordix(NX),Coordiy(NY),Coordiz(NZ)) !>Allocate the array in TIME_PARAMETER ALLOCATE(CTIME(NSTOP), STAT=ERR) ALLOCATE(DELT(0:NSTOP), STAT=ERR) allocate(Eps_r(nstop),Cq(nstop)) allocate(is_ex_in_source(nx,2:nyb-1),is_ey_in_source(2:nx,ny)) allocate(RecHzFile(NumRecHeights+1,NumRecLines),RecHEFile(NumRecHeights+1,NumRecLines)) allocate(RecFile(NumRecHeights+1,NumRecLines),RecFilePid(NumRecHeights+1,NumRecLines)) allocate(RecHzFilePid(NumRecHeights+1,NumRecLines),RecHEFilePid(NumRecHeights+1,NumRecLines)) allocate(Height(NumRecHeights)) !>THIS IS THE ARRAY FOR NON-UNIFORM GRID ALLOCATE(CDELX(NX),CDELY(NY),CDELZ(NZ),STAT=ERR) !>Arrays of the CPML absorbing boundary !! den_* = 1/kappa_* scaling arrays: always allocated; they are initialized to !! 1.0 in ZERO, and overwritten by Get_pml_parameters only when Logic_PML=1. !! So the iteration loop always multiplies the curl terms by den_*, and the !! scheme degenerates exactly to the original Dirichlet-boundary version !! (den=1, psi never updated) when the CPML boundary is disabled. ALLOCATE(den_ex(NX),den_hx(NX),den_ey(NY),den_hy(NY),den_ez(NZ),den_hz(NZ)) ALLOCATE(c_h_zz(NZ)) ALLOCATE(inv_hz_den(NZ)) IF(Logic_PML==1)THEN ALLOCATE(psi_Exy_1(NX,PML_Y1,NZB), psi_Exy_2(NX,PML_Y2,NZB), & psi_Exz_1(NX,NYB,PML_Z1), psi_Exz_2(NX,NYB,PML_Z2), & psi_Eyx_1(PML_X1,NY,NZB), psi_Eyx_2(PML_X2,NY,NZB), & psi_Eyz_1(NXB,NY,PML_Z1), psi_Eyz_2(NXB,NY,PML_Z2), & psi_Ezx_1(PML_X1,NYB,NZ), psi_Ezx_2(PML_X2,NYB,NZ), & psi_Ezy_1(NXB,PML_Y1,NZ), psi_Ezy_2(NXB,PML_Y2,NZ), & psi_Hxy_1(NXB,PML_Y1-1,NZ), psi_Hxy_2(NXB,PML_Y2-1,NZ),& psi_Hxz_1(NXB,NY,PML_Z1-1), psi_Hxz_2(NXB,NY,PML_Z2-1),& psi_Hyx_1(PML_X1-1,NYB,NZ), psi_Hyx_2(PML_X2-1,NYB,NZ),& psi_Hyz_1(NX,NYB,PML_Z1-1), psi_Hyz_2(NX,NYB,PML_Z2-1),& psi_Hzx_1(PML_X1-1,NY,NZB), psi_Hzx_2(PML_X2-1,NY,NZB),& psi_Hzy_1(NX,PML_Y1-1,NZB), psi_Hzy_2(NX,PML_Y2-1,NZB),& psi_Hzz_1(NX,NY,PML_Z1-1), psi_Hzz_2(NX,NY,PML_Z2-1),STAT=ERR) ALLOCATE(b_e_x1(PML_X1),c_e_x1(PML_X1),& alpha_PML_e_x1(PML_X1),sig_PML_e_x1(PML_X1),kappa_PML_e_x1(PML_X1)) ALLOCATE(b_h_x1(PML_X1-1),c_h_x1(PML_X1-1),& alpha_PML_h_x1(PML_X1-1),sig_PML_h_x1(PML_X1-1),kappa_PML_h_x1(PML_X1-1)) ALLOCATE(b_e_x2(PML_X2),c_e_x2(PML_X2),& alpha_PML_e_x2(PML_X2),sig_PML_e_x2(PML_X2),kappa_PML_e_x2(PML_X2)) ALLOCATE(b_h_x2(PML_X2-1),c_h_x2(PML_X2-1),& alpha_PML_h_x2(PML_X2-1),sig_PML_h_x2(PML_X2-1),kappa_PML_h_x2(PML_X2-1)) ALLOCATE(b_e_y1(PML_Y1),c_e_y1(PML_Y1),& alpha_PML_e_y1(PML_Y1),sig_PML_e_y1(PML_Y1),kappa_PML_e_y1(PML_Y1)) ALLOCATE(b_h_y1(PML_Y1-1),c_h_y1(PML_Y1-1),& alpha_PML_h_y1(PML_Y1-1),sig_PML_h_y1(PML_Y1-1),kappa_PML_h_y1(PML_Y1-1)) ALLOCATE(b_e_y2(PML_Y2),c_e_y2(PML_Y2),& alpha_PML_e_y2(PML_Y2),sig_PML_e_y2(PML_Y2),kappa_PML_e_y2(PML_Y2)) ALLOCATE(b_h_y2(PML_Y2-1),c_h_y2(PML_Y2-1),& alpha_PML_h_y2(PML_Y2-1),sig_PML_h_y2(PML_Y2-1),kappa_PML_h_y2(PML_Y2-1)) ALLOCATE(b_e_z1(PML_Z1),c_e_z1(PML_Z1),& alpha_PML_e_z1(PML_Z1),sig_PML_e_z1(PML_Z1),kappa_PML_e_z1(PML_Z1)) ALLOCATE(b_h_z1(PML_Z1-1),c_h_z1(PML_Z1-1),& alpha_PML_h_z1(PML_Z1-1),sig_PML_h_z1(PML_Z1-1),kappa_PML_h_z1(PML_Z1-1)) ALLOCATE(b_e_z2(PML_Z2),c_e_z2(PML_Z2),& alpha_PML_e_z2(PML_Z2),sig_PML_e_z2(PML_Z2),kappa_PML_e_z2(PML_Z2)) ALLOCATE(b_h_z2(PML_Z2-1),c_h_z2(PML_Z2-1),& alpha_PML_h_z2(PML_Z2-1),sig_PML_h_z2(PML_Z2-1),kappa_PML_h_z2(PML_Z2-1)) ENDIF RETURN ENDSUBROUTINE ALLOCATEMEMORY