diff --git a/CMakeLists.txt b/CMakeLists.txt index 75c35ef..373559f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.10) # set the project name set(CMAKE_PROJECT_NAME "SurfATT") -project(${CMAKE_PROJECT_NAME} VERSION 1.5.0 LANGUAGES Fortran CXX) +project(${CMAKE_PROJECT_NAME} VERSION 1.5.1 LANGUAGES Fortran CXX) # set the version number and git commit hash execute_process( @@ -12,8 +12,6 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -message(${GIT_COMMIT_HASH}) - configure_file( ${PROJECT_SOURCE_DIR}/include/version.h.in ${PROJECT_SOURCE_DIR}/include/version.h diff --git a/examples/04_hawaii_topo/run_this_example.sh b/examples/04_hawaii_topo/run_this_example.sh index fc89752..0861a2e 100644 --- a/examples/04_hawaii_topo/run_this_example.sh +++ b/examples/04_hawaii_topo/run_this_example.sh @@ -17,5 +17,8 @@ gmt grdcut @earth_relief_01m -R-157/-152/18/21 -Ghawaii.nc # inversion mpirun -np $NPROC ../../bin/surfatt_tomo -i input_params.yml +# rotate initial model +../../bin/surfatt_rotate_model -i OUTPUT_FILES/model_iter.h5 -a `echo $angle | awk '{print -$1}'` -c $pos_str -o OUTPUT_FILES/initial_model.csv -k vs_000 + # rotate back to original position ../../bin/surfatt_rotate_model -i OUTPUT_FILES/final_model.h5 -a `echo $angle | awk '{print -$1}'` -c $pos_str -o OUTPUT_FILES/final_model.csv \ No newline at end of file diff --git a/src/shared/argparse.f90 b/src/shared/argparse.f90 index 368d7db..ad2e842 100644 --- a/src/shared/argparse.f90 +++ b/src/shared/argparse.f90 @@ -249,14 +249,15 @@ subroutine argparse_rotate_topo(fname, xrange, yrange, angle, center, outfname) end subroutine argparse_rotate_topo - subroutine argparse_rotate_model(fname, angle, center, outfname) + subroutine argparse_rotate_model(fname, angle, center, outfname, keyname) use ieee_arithmetic character(len=MAX_STRING_LEN),dimension(:), allocatable :: args character(len=MAX_STRING_LEN) :: arg, value character(len=MAX_STRING_LEN),intent(out) :: fname, outfname + character(len=MAX_NAME_LEN),intent(out) :: keyname real(kind=dp), intent(out) :: angle, center(2) real(kind=dp) :: nan - integer :: i,nargs,m,ier,nopt=4 + integer :: i,nargs,m,ier,nopt=5 nargs = command_argument_count() allocate(args(nargs)) @@ -266,6 +267,7 @@ subroutine argparse_rotate_model(fname, angle, center, outfname) angle = 0. nan = ieee_value(nan, ieee_quiet_nan) center = [nan, nan] + keyname = 'vs' if (nargs==0 .or. any(args == '-h')) then write(*,*)'Usage: surfatt_rotate_model -i model_file -a angle -c clat/clon -o out_model_file' // & ' [-h]' @@ -282,6 +284,7 @@ subroutine argparse_rotate_model(fname, angle, center, outfname) write(*,*)' -a angle Angle in degree to rotate model' write(*,*)' -c clat/clon Center of rotation in latitude and longitude' write(*,*)' -h Print help message' + write(*,*)' -k keyname Key name of the variable to rotate, defaults to "vs"' endif m = 0 do i = 1, nargs @@ -301,6 +304,9 @@ subroutine argparse_rotate_model(fname, angle, center, outfname) elseif (arg(1:2) == '-o') then m = m+1 outfname = args(i+1) + elseif (arg(1:2) == '-k') then + m = m+1 + keyname = args(i+1) endif enddo if (m<1) then diff --git a/src/surfatt_rotate_model.f90 b/src/surfatt_rotate_model.f90 index d332c9d..d3a7973 100644 --- a/src/surfatt_rotate_model.f90 +++ b/src/surfatt_rotate_model.f90 @@ -22,6 +22,7 @@ program rotate_model implicit none character(len=MAX_STRING_LEN) :: input_file, output_file + character(len=MAX_NAME_LEN) :: keyname real(kind=dp) :: angle, center(2) real(kind=dp), dimension(:), allocatable :: lon, lat, dep, new_lat, new_lon real(kind=dp), dimension(:,:,:), allocatable :: vs3d @@ -31,14 +32,14 @@ program rotate_model logical :: status_ok integer :: i, j, k, nx, ny, nz - call argparse_rotate_model(input_file, angle, center, output_file) + call argparse_rotate_model(input_file, angle, center, output_file, keyname) ! Read the input file call hf%open(input_file) call hf%get('/lon', lon) call hf%get('/lat', lat) call hf%get('/dep', dep) - call hf%get('/vs', vs3d) + call hf%get('/'//trim(keyname), vs3d) call hf%close() vs3d = transpose_3(vs3d)