Simulation Core
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

write_vars.f90 2.6 KiB

vor 1 Jahr
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. module writevarsmodule
  2. use Simulator
  3. use RedisInterface
  4. contains
  5. subroutine InitDummyData()
  6. print *,"Initialize Dummy StringConfiguration ..."
  7. allocate(data%Configuration%StringConfiguration%StringConfigurations(2))
  8. data%Configuration%StringConfiguration%StringConfigurationCount =2
  9. data%Configuration%StringConfiguration%StringConfigurations(1)%Grade='A'
  10. data%Configuration%StringConfiguration%StringConfigurations(2)%Grade='B'
  11. print *,"Initialize Dummy Data ..."
  12. allocate(data%Configuration%Formation%Formations(2))
  13. data%Configuration%Formation%Count = 2
  14. data%Configuration%Formation%Formations(1)%Top = 0
  15. data%Configuration%Formation%Formations(2)%Top = 1000
  16. print *,"Initialize Dummy Data ..."
  17. allocate(data%Configuration%Path%Items(2))
  18. data%Configuration%Path%ItemCount = 2
  19. data%Configuration%Path%Items(1)%Length =1000
  20. data%Configuration%Path%Items(2)%Length =2000
  21. print *,"Initialize Dummy Data ..."
  22. end subroutine
  23. subroutine write_input_variables()
  24. use CAccumulator
  25. use json_module
  26. implicit none
  27. type(json_value),pointer :: jsonroot
  28. character(len=20)::fn
  29. ! integer::n_children
  30. call InitDummyData()
  31. ! ! allocate(data%Configuration%Path%DataPoints(3))
  32. ! allocate(data)
  33. call json%initialize()
  34. call json%create_object(jsonroot,'')
  35. call json%add(jsonroot,'status',simulationStatus)
  36. call json%add(jsonroot,'speed',simulationSpeed)
  37. call json%add(jsonroot,'endstep',simulationEnd)
  38. call ConfigurationToJson(jsonroot)
  39. ! call WarningsToJson(jsonroot)
  40. call ProblemsToJson(jsonroot)
  41. call EquipmentsToJson(jsonroot)
  42. ! call json%print(jsonroot,trim(fn)//".json")
  43. call json%serialize(jsonroot,redisInput)
  44. ! print *,"Writing to redis:",len(redisInput)
  45. ! nullify(redisContent)
  46. ! deallocate(redisContent)
  47. ! call json%destroy(pval)
  48. call setInput(redisInput)
  49. call json%print(jsonroot,'test.json')
  50. call json%destroy(jsonroot)
  51. print *,"write ends"
  52. end subroutine
  53. end module writevarsmodule
  54. program writeWars
  55. use json_module
  56. use writevarsmodule
  57. use RedisInterface
  58. implicit none
  59. character(len=50)::configFilename = "config-local.json"
  60. if(command_argument_count()>0) then
  61. call get_command_argument(1, configFilename)
  62. endif
  63. call initSimulation(configFilename)
  64. call initConnection(configFilename)
  65. ! call init_modules()
  66. call write_input_variables()
  67. end program writeWars