Simulation Core
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

82 行
2.7 KiB

  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 jsoncore%initialize()
  34. call jsoncore%create_object(jsonroot,'')
  35. call jsoncore%add(jsonroot,'status',simulationStatus)
  36. call jsoncore%add(jsonroot,'speed',simulationSpeed)
  37. call jsoncore%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 jsoncore%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 jsoncore%print(jsonroot,'test.json')
  50. call jsoncore%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