|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- module writevarsmodule
- use Simulator
- use RedisInterface
-
- contains
- subroutine InitDummyData()
- print *,"Initialize Dummy StringConfiguration ..."
- allocate(data%Configuration%StringConfiguration%StringConfigurations(2))
- data%Configuration%StringConfiguration%StringConfigurationCount =2
- data%Configuration%StringConfiguration%StringConfigurations(1)%Grade='A'
- data%Configuration%StringConfiguration%StringConfigurations(2)%Grade='B'
-
- print *,"Initialize Dummy Data ..."
- allocate(data%Configuration%Formation%Formations(2))
- data%Configuration%Formation%Count = 2
- data%Configuration%Formation%Formations(1)%Top = 0
- data%Configuration%Formation%Formations(2)%Top = 1000
-
- print *,"Initialize Dummy Data ..."
- allocate(data%Configuration%Path%Items(2))
- data%Configuration%Path%ItemCount = 2
- data%Configuration%Path%Items(1)%Length =1000
- data%Configuration%Path%Items(2)%Length =2000
- print *,"Initialize Dummy Data ..."
-
- end subroutine
-
- subroutine write_input_variables()
- use CAccumulator
- use json_module
- implicit none
- type(json_value),pointer :: jsonroot
- character(len=20)::fn
- ! integer::n_children
-
- call InitDummyData()
-
- ! ! allocate(data%Configuration%Path%DataPoints(3))
- ! allocate(data)
- call json%initialize()
- call json%create_object(jsonroot,'')
- call json%add(jsonroot,'status',simulationStatus)
- call json%add(jsonroot,'speed',simulationSpeed)
- call json%add(jsonroot,'endstep',simulationEnd)
-
- call ConfigurationToJson(jsonroot)
- ! call WarningsToJson(jsonroot)
- call ProblemsToJson(jsonroot)
- call EquipmentsToJson(jsonroot)
-
- ! call json%print(jsonroot,trim(fn)//".json")
- call json%serialize(jsonroot,redisInput)
- ! print *,"Writing to redis:",len(redisInput)
- ! nullify(redisContent)
- ! deallocate(redisContent)
- ! call json%destroy(pval)
- call setInput(redisInput)
- call json%print(jsonroot,'test.json')
- call json%destroy(jsonroot)
- print *,"write ends"
- end subroutine
-
- end module writevarsmodule
-
- program writeWars
- use json_module
- use writevarsmodule
- use RedisInterface
-
-
- implicit none
- character(len=50)::configFilename = "config-local.json"
-
- if(command_argument_count()>0) then
- call get_command_argument(1, configFilename)
- endif
-
- call initSimulation(configFilename)
- call initConnection(configFilename)
- ! call init_modules()
- call write_input_variables()
- end program writeWars
|