@@ -55,22 +55,19 @@ subroutine create_regions_mesh(npointot, &
5555 HDF5_ENABLED
5656
5757 use meshfem_par, only: &
58- myrank,nspec,nglob, iregion_code, &
58+ myrank,nspec,iregion_code, &
5959 ibool,idoubling,xstore,ystore,zstore, &
6060 xstore_glob,ystore_glob,zstore_glob
6161
6262 use meshfem_par, only: &
6363 NCHUNKS,SAVE_MESH_FILES,ABSORBING_CONDITIONS,LOCAL_PATH, &
6464 ADIOS_FOR_ARRAYS_SOLVER,ADIOS_FOR_SOLVER_MESHFILES, &
65- ROTATION,EXACT_MASS_MATRIX_FOR_ROTATION, GRAVITY_INTEGRALS, &
65+ GRAVITY_INTEGRALS, &
6666 FULL_GRAVITY, &
6767 NGLOB1D_RADIAL_CORNER, &
6868 NGLOB2DMAX_XMIN_XMAX,NGLOB2DMAX_YMIN_YMAX, &
6969 volume_total,Earth_mass_total,Earth_center_of_mass_x_total,Earth_center_of_mass_y_total,Earth_center_of_mass_z_total
7070
71- use meshfem_models_par, only: &
72- OCEANS
73-
7471#ifdef USE_CEM
7572 use meshfem_models_par, only: CEM_REQUEST
7673#endif
@@ -96,8 +93,8 @@ subroutine create_regions_mesh(npointot, &
9693 mu0store,Gc_prime_store,Gs_prime_store, &
9794 rho_vp,rho_vs, &
9895 Qmu_store,tau_e_store, &
99- nglob_xy, rmassx,rmassy,rmassz,b_rmassx,b_rmassy, &
100- nglob_oceans, rmass_ocean_load, &
96+ rmassx,rmassy,rmassz,b_rmassx,b_rmassy, &
97+ rmass_ocean_load, &
10198 iMPIcut_xi,iMPIcut_eta, &
10299 ispec_is_tiso
103100
@@ -129,9 +126,6 @@ subroutine create_regions_mesh(npointot, &
129126 ! now perform two passes in this part to be able to save memory
130127 integer ,intent (in ) :: ipass
131128
132- ! local parameters
133- integer :: ier
134-
135129 ! user output
136130 if (myrank == 0 ) then
137131 write (IMAIN,* )
@@ -374,71 +368,6 @@ subroutine create_regions_mesh(npointot, &
374368 write (IMAIN,* ) ' ...creating mass matrix'
375369 call flush_IMAIN()
376370 endif
377-
378- ! allocates mass matrices in this slice (will be fully assembled in the solver)
379- !
380- ! in the case of Stacey boundary conditions, add C*deltat/2 contribution to the mass matrix
381- ! on Stacey edges for the crust_mantle and outer_core regions but not for the inner_core region
382- ! thus the mass matrix must be replaced by three mass matrices including the "C" damping matrix
383- !
384- ! if absorbing_conditions are not set or if NCHUNKS=6, only one mass matrix is needed
385- ! for the sake of performance, only "rmassz" array will be filled and "rmassx" & "rmassy" will be obsolete
386- if (NCHUNKS /= 6 .and. ABSORBING_CONDITIONS) then
387- select case (iregion_code)
388- case (IREGION_CRUST_MANTLE)
389- nglob_xy = nglob
390- case (IREGION_INNER_CORE, IREGION_OUTER_CORE)
391- nglob_xy = 1
392- case (IREGION_TRINFINITE, IREGION_INFINITE)
393- nglob_xy = 1
394- case default
395- call exit_mpi(myrank,' Invalid region code for nglob_xy' )
396- end select
397- else
398- nglob_xy = 1
399- endif
400-
401- if (ROTATION .and. EXACT_MASS_MATRIX_FOR_ROTATION) then
402- select case (iregion_code)
403- case (IREGION_CRUST_MANTLE,IREGION_INNER_CORE)
404- nglob_xy = nglob
405- case (IREGION_OUTER_CORE)
406- nglob_xy = 1
407- case (IREGION_TRINFINITE, IREGION_INFINITE)
408- nglob_xy = 1
409- case default
410- call exit_mpi(myrank,' Invalid region code for nglob_xy with EXACT_MASS_MATRIX_FOR_ROTATION' )
411- end select
412- endif
413-
414- allocate (rmassx(nglob_xy), &
415- rmassy(nglob_xy), &
416- stat= ier)
417- if (ier /= 0 ) stop ' Error in allocate 21'
418- rmassx(:) = 0.0_CUSTOM_REAL
419- rmassy(:) = 0.0_CUSTOM_REAL
420-
421- allocate (b_rmassx(nglob_xy), &
422- b_rmassy(nglob_xy),stat= ier)
423- if (ier /= 0 ) stop ' Error in allocate b_21'
424- b_rmassx(:) = 0.0_CUSTOM_REAL
425- b_rmassy(:) = 0.0_CUSTOM_REAL
426-
427- allocate (rmassz(nglob),stat= ier)
428- if (ier /= 0 ) stop ' Error in allocate 22'
429- rmassz(:) = 0.0_CUSTOM_REAL
430-
431- ! allocates ocean load mass matrix as well if oceans
432- if (OCEANS .and. iregion_code == IREGION_CRUST_MANTLE) then
433- nglob_oceans = nglob
434- else
435- ! allocate dummy array if no oceans
436- nglob_oceans = 1
437- endif
438- allocate (rmass_ocean_load(nglob_oceans),stat= ier)
439- if (ier /= 0 ) stop ' Error in allocate 22'
440- rmass_ocean_load(:) = 0.0_CUSTOM_REAL
441-
442371 ! creating mass matrices in this slice (will be fully assembled in the solver)
443372 ! note: for Stacey boundaries, needs indexing nimin,.. filled in the first pass
444373 call create_mass_matrices(idoubling,ibool, &
@@ -522,25 +451,6 @@ subroutine create_regions_mesh(npointot, &
522451
523452 endif ! .not. GRAVITY_INTEGRALS
524453
525- ! synchronizes processes before clean up memory
526- call synchronize_all()
527-
528- ! frees memory
529- deallocate (rmassx,rmassy,rmassz)
530- deallocate (b_rmassx,b_rmassy)
531- deallocate (rmass_ocean_load)
532- ! frees allocated mesh memory
533- deallocate (xstore_glob,ystore_glob,zstore_glob)
534- ! frees MPI arrays memory
535- call crm_free_MPI_arrays()
536- ! free Stacey helper arrays (not needed anymore)
537- if (allocated (nimin)) deallocate (nimin,nimax,njmin,njmax,nkmin_xi,nkmin_eta)
538- if (allocated (abs_boundary_ispec)) then
539- deallocate (abs_boundary_ispec,abs_boundary_npoin,abs_boundary_ijk)
540- deallocate (abs_boundary_jacobian2Dw)
541- deallocate (abs_boundary_normal)
542- endif
543-
544454 ! compute volume, bottom and top area of that part of the slice, and then the total
545455 call compute_volumes_and_areas(NCHUNKS,iregion_code,nspec,wxgll,wygll,wzgll, &
546456 xixstore,xiystore,xizstore,etaxstore,etaystore,etazstore,gammaxstore,gammaystore,gammazstore, &
@@ -569,6 +479,25 @@ subroutine create_regions_mesh(npointot, &
569479
570480 endif
571481
482+ ! synchronizes processes before clean up memory
483+ call synchronize_all()
484+
485+ ! frees memory
486+ deallocate (rmassx,rmassy,rmassz)
487+ deallocate (b_rmassx,b_rmassy)
488+ deallocate (rmass_ocean_load)
489+ ! frees allocated mesh memory
490+ deallocate (xstore_glob,ystore_glob,zstore_glob)
491+ ! frees MPI arrays memory
492+ call crm_free_MPI_arrays()
493+ ! free Stacey helper arrays (not needed anymore)
494+ if (allocated (nimin)) deallocate (nimin,nimax,njmin,njmax,nkmin_xi,nkmin_eta)
495+ if (allocated (abs_boundary_ispec)) then
496+ deallocate (abs_boundary_ispec,abs_boundary_npoin,abs_boundary_ijk)
497+ deallocate (abs_boundary_jacobian2Dw)
498+ deallocate (abs_boundary_normal)
499+ endif
500+
572501 case default
573502 stop ' there cannot be more than two passes in mesh creation'
574503
0 commit comments