aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-04-05 16:30:15 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-04-05 16:30:15 -0400
commitaef2c3629718705975a181a345d3908776b14af5 (patch)
treee17ce550c12f1bd173a3e5a39f6388ca300e6651 /common
parent15837a5fd46a1c9051d54138ba3ade26c74091f1 (diff)
downloadlevitating-aef2c3629718705975a181a345d3908776b14af5.tar.gz
levitating-aef2c3629718705975a181a345d3908776b14af5.zip
Fixed checkin json to return a name of instructions needed and a job id
Diffstat (limited to 'common')
-rw-r--r--common/utilities.F9056
1 files changed, 56 insertions, 0 deletions
diff --git a/common/utilities.F90 b/common/utilities.F90
index 895e604..d4b7b81 100644
--- a/common/utilities.F90
+++ b/common/utilities.F90
@@ -6,6 +6,11 @@ module utilities
character, parameter::dir_sep = '/'
#endif
+ interface replace_field
+ module procedure replace_field_text
+ module procedure replace_field_int
+ end interface
+
contains
function is_absolute_path(path)
@@ -219,4 +224,55 @@ contains
end subroutine delete_file
+ subroutine replace_field_text(str, field, val)
+ implicit none
+
+ character(*), intent(inout)::str
+ character(*), intent(in)::field
+ character(*), intent(in)::val
+
+ character(len=:), allocatable::holding
+ integer::length_estimate
+ integer::field_location, i
+
+ ! This is too big, but close enough
+ length_estimate = len_trim(str) + len_trim(val)
+ allocate(character(len=length_estimate) :: holding)
+ holding = " "
+
+ print *, trim(str)
+
+ ! Find the field
+ field_location = index(str, "{"//trim(field)//"}")
+ if(field_location > 0) then
+
+ i = field_location + len_trim(field) + 2
+ holding = str(1:field_location-1)//trim(val)//str(i:len_trim(str))
+
+ ! Put the results back now
+ str = holding
+
+ end if
+
+ print *, trim(str)
+
+ deallocate(holding)
+
+ end subroutine replace_field_text
+
+ subroutine replace_field_int(str, field, val)
+ implicit none
+
+ character(*), intent(inout)::str
+ character(*), intent(in)::field
+ integer, intent(in)::val
+
+ character(16)::int_text
+
+ write(int_text, *) val
+
+ call replace_field_text(str, field, trim(adjustl(int_text)))
+
+ end subroutine replace_field_int
+
end module utilities \ No newline at end of file