Skip to content

Commit

Permalink
adding optional NAME field to external model field
Browse files Browse the repository at this point in the history
also adding this to the netcdf output to be used in instaseis. Hence increasing the file
version number.
  • Loading branch information
martinvandriel committed Sep 25, 2015
1 parent d9037df commit ef523e7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 18 deletions.
13 changes: 13 additions & 0 deletions MESHER/background_models.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,12 @@ end function arbitr_sub_solar
subroutine read_ext_model(fnam_ext_model, nlayer_out, rho_layer_out, &
vpv_layer_out, vsv_layer_out, radius_layer_out)

#ifdef solver
use data_mesh, only: model_name_ext_model
#else
use data_bkgrdmodel, only: model_name_ext_model
#endif

character(len=*), intent(in) :: fnam_ext_model
real(kind=dp), allocatable, intent(out), optional :: vpv_layer_out(:)
real(kind=dp), allocatable, intent(out), optional :: vsv_layer_out(:)
Expand All @@ -1459,6 +1465,7 @@ subroutine read_ext_model(fnam_ext_model, nlayer_out, rho_layer_out, &
logical :: model_in_depth = .false., model_in_km = .false.
logical :: exist_param_units = .false., exist_param_col = .false.
logical :: exist_param_anel = .false., exist_param_ani = .false.
logical :: exist_param_name = .false.
logical :: override_radius = .false.
character(len=128) :: fmtstring, keyword, keyvalue
character(len=512) :: line
Expand All @@ -1483,6 +1490,7 @@ subroutine read_ext_model(fnam_ext_model, nlayer_out, rho_layer_out, &
ierr = 0
nerr = 0
iline = 0
model_name_ext_model = 'external_model'

do while (ierr==0)
read(77, fmt='(a512)', iostat=ierr) line
Expand All @@ -1494,6 +1502,10 @@ subroutine read_ext_model(fnam_ext_model, nlayer_out, rho_layer_out, &

call check_line_err(line_err, iline, line, trim(fnam_ext_model), nerr)
select case(keyword)
case('NAME')
call check_already_defined(exist_param_name, keyword, iline, trim(fnam_ext_model), nerr)
model_name_ext_model = trim(keyvalue)
exist_param_name = .true.
case('ANELASTIC')
call check_already_defined(exist_param_anel, keyword, iline, trim(fnam_ext_model), nerr)
read(keyvalue, *) ext_model_is_anelastic
Expand Down Expand Up @@ -1566,6 +1578,7 @@ subroutine read_ext_model(fnam_ext_model, nlayer_out, rho_layer_out, &

read(line,*) keyword, keyvalue
select case(keyword)
case('NAME')
case('ANISOTROPIC')
case('ANELASTIC')
case('UNITS')
Expand Down
1 change: 1 addition & 0 deletions MESHER/data_bkgrdmodel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module data_bkgrdmodel

! The following variables are only needed by external models
character(len=100) :: fnam_ext_model
character(len=100) :: model_name_ext_model = ''

end module data_bkgrdmodel
!=========================================================================================
1 change: 1 addition & 0 deletions MESHER/external_model.TEMPLATE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Input file for AXISEM created from PREM_ani on 02/02/2014, at 10h 39min
NAME PREM_ani

# Is model anelastic?
ANELASTIC T
Expand Down
14 changes: 11 additions & 3 deletions MESHER/model_discontinuities.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1255,9 +1255,17 @@ subroutine write_1Dmodel(discontinuities)
call date_and_time(mydate,mytime)

open(2000, file=fnam, action='write')
11 format('# Input file for AXISEM created from external model on ', &
A2,'/',A2,'/',A4,', at ',A2,'h ',A2,'min')
write(2000,11) mydate(7:8), mydate(5:6), mydate(1:4), mytime(1:2), mytime(3:4)
write(2000,"('# Input file for AXISEM created from ', A, ' model on ', &
A2, '/', A2, '/', A4, ', at ', A2, 'h ', A2, 'min')") &
trim(bkgrdmodel), mydate(7:8), mydate(5:6), mydate(1:4), mytime(1:2), mytime(3:4)


if (trim(bkgrdmodel) == 'external') then
write(2000,'("NAME ", A)') trim(model_name_ext_model)
else
write(2000,'("NAME ", A)') trim(bkgrdmodel)
endif

write(2000,'("ANELASTIC ", L4)') model_is_anelastic(bkgrdmodel)
write(2000,'("ANISOTROPIC ", L4)') model_is_ani(bkgrdmodel)
write(2000,'("UNITS m")')
Expand Down
27 changes: 14 additions & 13 deletions SOLVER/data_mesh.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ module data_mesh
public

! Very basic mesh parameters, have been in mesh_params.h before
integer , protected :: npol !< polynomial order
integer , protected :: nelem !< proc. els
integer , protected :: npoint !< proc. all pts
integer , protected :: nel_solid !< proc. solid els
integer , protected :: nel_fluid !< proc. fluid els
integer , protected :: npoint_solid !< proc. solid pts
integer , protected :: npoint_fluid !< proc. fluid pts
integer , protected :: nglob_solid !< proc. slocal pts
integer , protected :: nglob_fluid !< proc. flocal pts
integer , protected :: nel_bdry !< proc. solid-fluid bndry els
integer , protected :: ndisc !< # disconts in bkgrd model
integer , protected :: nproc_mesh !< number of processors
integer , protected :: lfbkgrdmodel !< length of bkgrdmodel name
integer, protected :: npol !< polynomial order
integer, protected :: nelem !< proc. els
integer, protected :: npoint !< proc. all pts
integer, protected :: nel_solid !< proc. solid els
integer, protected :: nel_fluid !< proc. fluid els
integer, protected :: npoint_solid !< proc. solid pts
integer, protected :: npoint_fluid !< proc. fluid pts
integer, protected :: nglob_solid !< proc. slocal pts
integer, protected :: nglob_fluid !< proc. flocal pts
integer, protected :: nel_bdry !< proc. solid-fluid bndry els
integer, protected :: ndisc !< # disconts in bkgrd model
integer, protected :: nproc_mesh !< number of processors
integer, protected :: lfbkgrdmodel !< length of bkgrdmodel name

! global number in solid varies across procs due to central cube domain decomposition
integer :: nglob
Expand All @@ -73,6 +73,7 @@ module data_mesh

! Global mesh informations
real(kind=dp) :: router ! Outer radius (surface)
character(len=100) :: model_name_ext_model ! name of external model

! critical mesh parameters (spacing/velocity, characteristic lead time etc)
real(kind=dp) :: pts_wavelngth
Expand Down
2 changes: 1 addition & 1 deletion SOLVER/get_mesh.f90
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ subroutine read_db
if (verbose > 1.and.lpr) print *, ' Background model: ', trim(bkgrdmodel)

if (trim(bkgrdmodel).eq.'external') then
if (verbose > 1.and.lpr) write(69,*)'reading external velocity model file...'
if (verbose > 1.and.lpr) write(*,*)'reading external velocity model file...'
call get_ext_disc('./external_model.bm')
end if

Expand Down
3 changes: 2 additions & 1 deletion SOLVER/parameters.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1450,8 +1450,9 @@ subroutine write_parameters
#endif
! write generic simulation info file
if (mynum == 0) write(6,*) ' Writing simulation info to netcdf file attributes'
call nc_write_att_int( 7, 'file version')
call nc_write_att_int( 8, 'file version')
call nc_write_att_char( trim(bkgrdmodel), 'background model')
call nc_write_att_char( trim(model_name_ext_model), 'external model name')
call nc_write_att_int( merge(1, 0, do_anel), 'attenuation') ! merge: hacky conversion of logical to int
call nc_write_att_dble( router / 1000, 'planet radius')
call nc_write_att_char( trim(mydatetime), 'datetime')
Expand Down

0 comments on commit ef523e7

Please sign in to comment.