Browse Source

json deserialize OK

master
mahmood19227 1 year ago
parent
commit
be27401da2
42 changed files with 704 additions and 281 deletions
  1. +27
    -3
      .vscode/launch.json
  2. +5
    -0
      .vscode/settings.json
  3. +7
    -2
      CSharp/BasicInputs/Bha/CStringConfiguration.f90
  4. +7
    -2
      CSharp/BasicInputs/Bha/CStringConfiguration.i90
  5. +2
    -2
      CSharp/BasicInputs/CMudPropertiesVariables.f90
  6. +2
    -2
      CSharp/BasicInputs/CMudPropertiesVariables.i90
  7. +26
    -0
      CSharp/BasicInputs/Geology/CReservoirVariables.i90
  8. +7
    -7
      CSharp/BasicInputs/MudProperties.f90
  9. +7
    -7
      CSharp/BasicInputs/MudProperties.i90
  10. +19
    -0
      CSharp/BasicInputs/RigSpecifications/CAccumulatorVariables.i90
  11. +19
    -0
      CSharp/BasicInputs/RigSpecifications/CHoistingVariables.i90
  12. +17
    -17
      CSharp/BasicInputs/RigSpecifications/CPumps.f90
  13. +17
    -17
      CSharp/BasicInputs/RigSpecifications/CPumps.i90
  14. +6
    -6
      CSharp/BasicInputs/RigSpecifications/CPumpsVariables.f90
  15. +6
    -6
      CSharp/BasicInputs/RigSpecifications/CPumpsVariables.i90
  16. +16
    -0
      CSharp/BasicInputs/RigSpecifications/CRigSizeVariables.i90
  17. +8
    -5
      CSharp/BasicInputs/WellProfile/CPathGeneration.f90
  18. +8
    -5
      CSharp/BasicInputs/WellProfile/CPathGeneration.i90
  19. +1
    -3
      CSharp/BasicInputs/WellProfile/CPathGenerationVariables.f90
  20. +1
    -3
      CSharp/BasicInputs/WellProfile/CPathGenerationVariables.i90
  21. +1
    -31
      CSharp/Common/CCommon.f90
  22. +21
    -0
      CSharp/Common/CCommon.i90
  23. +159
    -0
      Common/DynamicRealArray.i90
  24. +11
    -7
      Redis/Redis_Interface.f90
  25. +11
    -7
      Redis/Redis_Interface.i90
  26. +1
    -1
      Redis/example_redis.c
  27. +14
    -8
      Redis/redis_io.c
  28. BIN
     
  29. BIN
     
  30. BIN
     
  31. +21
    -22
      Simulator.f90
  32. +21
    -22
      Simulator.i90
  33. +32
    -14
      Test/testJson.f90
  34. +32
    -14
      Test/testJson.i90
  35. BIN
     
  36. +0
    -7
      TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.f90
  37. +105
    -0
      TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.i90
  38. +3
    -3
      config-debug.json
  39. BIN
     
  40. +37
    -33
      redisContent.json
  41. +24
    -24
      test.json
  42. +3
    -1
      todo.txt

+ 27
- 3
.vscode/launch.json View File

@@ -1,17 +1,41 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "Debug SimulationCore2",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/SimulationCore2_DEBUG",
"args": ["Config-debug.json"],
"program": "${workspaceRoot}/SimulationCore2",
"args": ["Config-local.json"],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": false,
"MIMode": "gdb",
// "preLaunchTask": "make debug",
"preLaunchTask": "make",
},
{
"name": "Debug write_vars",


+ 5
- 0
.vscode/settings.json View File

@@ -0,0 +1,5 @@
{
"files.associations": {
"hiredis.h": "c"
}
}

+ 7
- 2
CSharp/BasicInputs/Bha/CStringConfiguration.f90 View File

@@ -13,7 +13,6 @@ module CStringConfiguration
type(json_core) :: json
type(json_value),pointer :: p,pitems,pitem,pval,pbit
logical::is_found
type(CStringItem) :: item
integer::i,n_children
CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val
@@ -22,9 +21,15 @@ module CStringConfiguration
call json%get(p,'StringConfigurationItems',pitems)
call json%info(pitems, n_children=n_children)
if (.not. allocated(data%Configuration%StringConfiguration%StringConfigurations) .or. size(data%Configuration%StringConfiguration%StringConfigurations)/=n_children) then
if (.not. allocated(data%Configuration%StringConfiguration%StringConfigurations)) then
ALLOCATE(data%Configuration%StringConfiguration%StringConfigurations(n_children))
endif
if(size(data%Configuration%StringConfiguration%StringConfigurations)/=n_children) then
DEALLOCATE(data%Configuration%StringConfiguration%StringConfigurations)
ALLOCATE(data%Configuration%StringConfiguration%StringConfigurations(n_children))
endif
do i=1,n_children
call json%get_child(pitems, i, pitem, found=is_found)


+ 7
- 2
CSharp/BasicInputs/Bha/CStringConfiguration.i90 View File

@@ -14,7 +14,6 @@ module CStringConfiguration
type(json_core) :: json
type(json_value),pointer :: p,pitems,pitem,pval,pbit
logical::is_found
type(CStringItem) :: item
integer::i,n_children
CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val

@@ -23,9 +22,15 @@ module CStringConfiguration

call json%get(p,'StringConfigurationItems',pitems)
call json%info(pitems, n_children=n_children)
if (.not. allocated(data%Configuration%StringConfiguration%StringConfigurations) .or. size(data%Configuration%StringConfiguration%StringConfigurations)/=n_children) then
if (.not. allocated(data%Configuration%StringConfiguration%StringConfigurations)) then
ALLOCATE(data%Configuration%StringConfiguration%StringConfigurations(n_children))
endif
if(size(data%Configuration%StringConfiguration%StringConfigurations)/=n_children) then
DEALLOCATE(data%Configuration%StringConfiguration%StringConfigurations)
ALLOCATE(data%Configuration%StringConfiguration%StringConfigurations(n_children))
endif


do i=1,n_children
call json%get_child(pitems, i, pitem, found=is_found)


+ 2
- 2
CSharp/BasicInputs/CMudPropertiesVariables.f90 View File

@@ -36,8 +36,8 @@ module CMudPropertiesVariables
real(8) :: ActiveTotalTankCapacityGal
real(8) :: ActiveSettledContents
real(8) :: ActiveSettledContentsGal
real(8) :: ActiveTotalContents
real(8) :: ActiveTotalContentsGal
! real(8) :: ActiveTotalContents
! real(8) :: ActiveTotalContentsGal
logical :: ActiveAutoDensity
real(8) :: InitialTripTankMudVolume
real(8) :: InitialTripTankMudVolumeGal


+ 2
- 2
CSharp/BasicInputs/CMudPropertiesVariables.i90 View File

@@ -37,8 +37,8 @@ module CMudPropertiesVariables
real(8) :: ActiveTotalTankCapacityGal
real(8) :: ActiveSettledContents
real(8) :: ActiveSettledContentsGal
real(8) :: ActiveTotalContents
real(8) :: ActiveTotalContentsGal
! real(8) :: ActiveTotalContents
! real(8) :: ActiveTotalContentsGal
logical :: ActiveAutoDensity
real(8) :: InitialTripTankMudVolume
real(8) :: InitialTripTankMudVolumeGal


+ 26
- 0
CSharp/BasicInputs/Geology/CReservoirVariables.i90 View File

@@ -0,0 +1,26 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/Geology/CReservoirVariables.f90"
module CReservoirVariables
implicit none
public
!constants
! integer :: Gas_FluidType = 0
! integer :: Oil_FluidType = 1
! integer :: Water_FluidType = 2
Type :: ReservoirType
! variables
integer :: FormationNo
real(8) :: FormationTop
real(8) :: PressureGradient
real(8) :: FormationPermeability
real(8) :: GeothermalGradient
integer :: FluidType
real(8) :: FluidGradient
real(8) :: FluidViscosity
logical :: InactiveInflux
logical :: IsAutoMigrationRateSelected
real(8) :: AutoMigrationRate
logical :: MakeKickSinglePacket
End type ReservoirType
Type(ReservoirType)::Reservoir
end module CReservoirVariables

+ 7
- 7
CSharp/BasicInputs/MudProperties.f90 View File

@@ -36,8 +36,8 @@ module MudPropertiesModule
call json%add(p,"ActiveTotalTankCapacityGal",data%Configuration%Mud%ActiveTotalTankCapacityGal)
call json%add(p,"ActiveSettledContents",data%Configuration%Mud%ActiveSettledContents)
call json%add(p,"ActiveSettledContentsGal",data%Configuration%Mud%ActiveSettledContentsGal)
call json%add(p,"ActiveTotalContents",data%Configuration%Mud%ActiveTotalContents)
call json%add(p,"ActiveTotalContentsGal",data%Configuration%Mud%ActiveTotalContentsGal)
! call json%add(p,"ActiveTotalContents",data%Configuration%Mud%ActiveTotalContents)
! call json%add(p,"ActiveTotalContentsGal",data%Configuration%Mud%ActiveTotalContentsGal)
call json%add(p,"ActiveAutoDensity",data%Configuration%Mud%ActiveAutoDensity)
call json%add(p,"InitialTripTankMudVolume",data%Configuration%Mud%InitialTripTankMudVolume)
call json%add(p,"InitialTripTankMudVolumeGal",data%Configuration%Mud%InitialTripTankMudVolumeGal)
@@ -51,7 +51,7 @@ module MudPropertiesModule
use json_module,IK =>json_ik
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p,pitems,pitem,pval,pbit
type(json_value),pointer :: p,pitem
call json%get(parent,'Mud',p)
@@ -97,10 +97,10 @@ module MudPropertiesModule
call json%get(pitem,data%Configuration%Mud%ActiveSettledContents)
call json%get(p,"ActiveSettledContentsGal",pitem)
call json%get(pitem,data%Configuration%Mud%ActiveSettledContentsGal)
call json%get(p,"ActiveTotalContents",pitem)
call json%get(pitem,data%Configuration%Mud%ActiveTotalContents)
call json%get(p,"ActiveTotalContentsGal",pitem)
call json%get(pitem,data%Configuration%Mud%ActiveTotalContentsGal)
! call json%get(p,"ActiveTotalContents",pitem)
! call json%get(pitem,data%Configuration%Mud%ActiveTotalContents)
! call json%get(p,"ActiveTotalContentsGal",pitem)
! call json%get(pitem,data%Configuration%Mud%ActiveTotalContentsGal)
call json%get(p,"ActiveAutoDensity",pitem)
call json%get(pitem,data%Configuration%Mud%ActiveAutoDensity)
call json%get(p,"InitialTripTankMudVolume",pitem)


+ 7
- 7
CSharp/BasicInputs/MudProperties.i90 View File

@@ -37,8 +37,8 @@ module MudPropertiesModule
call json%add(p,"ActiveTotalTankCapacityGal",data%Configuration%Mud%ActiveTotalTankCapacityGal)
call json%add(p,"ActiveSettledContents",data%Configuration%Mud%ActiveSettledContents)
call json%add(p,"ActiveSettledContentsGal",data%Configuration%Mud%ActiveSettledContentsGal)
call json%add(p,"ActiveTotalContents",data%Configuration%Mud%ActiveTotalContents)
call json%add(p,"ActiveTotalContentsGal",data%Configuration%Mud%ActiveTotalContentsGal)
! call json%add(p,"ActiveTotalContents",data%Configuration%Mud%ActiveTotalContents)
! call json%add(p,"ActiveTotalContentsGal",data%Configuration%Mud%ActiveTotalContentsGal)
call json%add(p,"ActiveAutoDensity",data%Configuration%Mud%ActiveAutoDensity)
call json%add(p,"InitialTripTankMudVolume",data%Configuration%Mud%InitialTripTankMudVolume)
call json%add(p,"InitialTripTankMudVolumeGal",data%Configuration%Mud%InitialTripTankMudVolumeGal)
@@ -52,7 +52,7 @@ module MudPropertiesModule
use json_module,IK =>json_ik
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p,pitems,pitem,pval,pbit
type(json_value),pointer :: p,pitem

call json%get(parent,'Mud',p)

@@ -98,10 +98,10 @@ module MudPropertiesModule
call json%get(pitem,data%Configuration%Mud%ActiveSettledContents)
call json%get(p,"ActiveSettledContentsGal",pitem)
call json%get(pitem,data%Configuration%Mud%ActiveSettledContentsGal)
call json%get(p,"ActiveTotalContents",pitem)
call json%get(pitem,data%Configuration%Mud%ActiveTotalContents)
call json%get(p,"ActiveTotalContentsGal",pitem)
call json%get(pitem,data%Configuration%Mud%ActiveTotalContentsGal)
! call json%get(p,"ActiveTotalContents",pitem)
! call json%get(pitem,data%Configuration%Mud%ActiveTotalContents)
! call json%get(p,"ActiveTotalContentsGal",pitem)
! call json%get(pitem,data%Configuration%Mud%ActiveTotalContentsGal)
call json%get(p,"ActiveAutoDensity",pitem)
call json%get(pitem,data%Configuration%Mud%ActiveAutoDensity)
call json%get(p,"InitialTripTankMudVolume",pitem)


+ 19
- 0
CSharp/BasicInputs/RigSpecifications/CAccumulatorVariables.i90 View File

@@ -0,0 +1,19 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/RigSpecifications/CAccumulatorVariables.f90"
module CAccumulatorVariables
implicit none
public
Type:: AccumulatorType
integer :: NumberOfBottels
real(8) :: AccumulatorSystemSize
real(8) :: OilTankVolume
real(8) :: PrechargePressure
real(8) :: AccumulatorMinimumOperatingPressure
real(8) :: ElectricPumpOutput
real(8) :: StartPressure
real(8) :: StopPressure
real(8) :: AirPlungerPumpOutput
real(8) :: StartPressure2
real(8) :: StopPressure2
End Type AccumulatorType
! Type(AccumulatorType)::Accumulator
end module CAccumulatorVariables

+ 19
- 0
CSharp/BasicInputs/RigSpecifications/CHoistingVariables.i90 View File

@@ -0,0 +1,19 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/RigSpecifications/CHoistingVariables.f90"
module CHoistingVariables
implicit none
public
!constants
integer :: TopDrive_DriveType = 0
integer :: Kelly_DriveType = 1

! variables
Type::HoistingType
integer :: DriveType
real(8) :: TravelingBlockWeight
real(8) :: TopDriveWeight
real(8) :: KellyWeight
integer :: NumberOfLine
real(8) :: DrillingLineBreakingLoad
End type HoistingType
end module CHoistingVariables

+ 17
- 17
CSharp/BasicInputs/RigSpecifications/CPumps.f90 View File

@@ -44,12 +44,12 @@ module CPumps
call json%add(p,"MudPump1ReliefValveIsSet",data%Configuration%Pumps%MudPump1ReliefValveIsSet)
call json%add(p,"MudPump2ReliefValveIsSet",data%Configuration%Pumps%MudPump2ReliefValveIsSet)
call json%add(p,"CementPumpReliefValveIsSet",data%Configuration%Pumps%CementPumpReliefValveIsSet)
call json%add(p,"ManualPumpPower",data%Configuration%Pumps%ManualPumpPower)
call json%add(p,"Valve1",data%Configuration%Pumps%Valve1)
call json%add(p,"Valve2",data%Configuration%Pumps%Valve2)
call json%add(p,"Valve3",data%Configuration%Pumps%Valve3)
call json%add(p,"Valve4",data%Configuration%Pumps%Valve4)
call json%add(p,"Valve5",data%Configuration%Pumps%Valve5)
! call json%add(p,"ManualPumpPower",data%Configuration%Pumps%ManualPumpPower)
! call json%add(p,"Valve1",data%Configuration%Pumps%Valve1)
! call json%add(p,"Valve2",data%Configuration%Pumps%Valve2)
! call json%add(p,"Valve3",data%Configuration%Pumps%Valve3)
! call json%add(p,"Valve4",data%Configuration%Pumps%Valve4)
! call json%add(p,"Valve5",data%Configuration%Pumps%Valve5)
! 3. add new node to parent
call json%add(parent,p)
@@ -118,17 +118,17 @@ module CPumps
call json%get(p,"CementPumpReliefValveIsSet",pitem)
call json%get(pitem,data%Configuration%Pumps%CementPumpReliefValveIsSet)
call json%get(p,"ManualPumpPower",pitem)
call json%get(pitem,data%Configuration%Pumps%ManualPumpPower)
call json%get(p,"Valve1",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve1)
call json%get(p,"Valve2",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve2)
call json%get(p,"Valve3",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve3)
call json%get(p,"Valve4",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve4)
call json%get(p,"Valve5",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve5)
! call json%get(pitem,data%Configuration%Pumps%ManualPumpPower)
! call json%get(p,"Valve1",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve1)
! call json%get(p,"Valve2",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve2)
! call json%get(p,"Valve3",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve3)
! call json%get(p,"Valve4",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve4)
! call json%get(p,"Valve5",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve5)
end subroutine


+ 17
- 17
CSharp/BasicInputs/RigSpecifications/CPumps.i90 View File

@@ -45,12 +45,12 @@ module CPumps
call json%add(p,"MudPump1ReliefValveIsSet",data%Configuration%Pumps%MudPump1ReliefValveIsSet)
call json%add(p,"MudPump2ReliefValveIsSet",data%Configuration%Pumps%MudPump2ReliefValveIsSet)
call json%add(p,"CementPumpReliefValveIsSet",data%Configuration%Pumps%CementPumpReliefValveIsSet)
call json%add(p,"ManualPumpPower",data%Configuration%Pumps%ManualPumpPower)
call json%add(p,"Valve1",data%Configuration%Pumps%Valve1)
call json%add(p,"Valve2",data%Configuration%Pumps%Valve2)
call json%add(p,"Valve3",data%Configuration%Pumps%Valve3)
call json%add(p,"Valve4",data%Configuration%Pumps%Valve4)
call json%add(p,"Valve5",data%Configuration%Pumps%Valve5)
! call json%add(p,"ManualPumpPower",data%Configuration%Pumps%ManualPumpPower)
! call json%add(p,"Valve1",data%Configuration%Pumps%Valve1)
! call json%add(p,"Valve2",data%Configuration%Pumps%Valve2)
! call json%add(p,"Valve3",data%Configuration%Pumps%Valve3)
! call json%add(p,"Valve4",data%Configuration%Pumps%Valve4)
! call json%add(p,"Valve5",data%Configuration%Pumps%Valve5)
! 3. add new node to parent
call json%add(parent,p)
@@ -119,17 +119,17 @@ module CPumps
call json%get(p,"CementPumpReliefValveIsSet",pitem)
call json%get(pitem,data%Configuration%Pumps%CementPumpReliefValveIsSet)
call json%get(p,"ManualPumpPower",pitem)
call json%get(pitem,data%Configuration%Pumps%ManualPumpPower)
call json%get(p,"Valve1",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve1)
call json%get(p,"Valve2",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve2)
call json%get(p,"Valve3",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve3)
call json%get(p,"Valve4",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve4)
call json%get(p,"Valve5",pitem)
call json%get(pitem,data%Configuration%Pumps%Valve5)
! call json%get(pitem,data%Configuration%Pumps%ManualPumpPower)
! call json%get(p,"Valve1",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve1)
! call json%get(p,"Valve2",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve2)
! call json%get(p,"Valve3",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve3)
! call json%get(p,"Valve4",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve4)
! call json%get(p,"Valve5",pitem)
! call json%get(pitem,data%Configuration%Pumps%Valve5)

end subroutine



+ 6
- 6
CSharp/BasicInputs/RigSpecifications/CPumpsVariables.f90 View File

@@ -37,12 +37,12 @@ module CPumpsVariables
logical :: MudPump2ReliefValveIsSet
logical :: CementPumpReliefValveIsSet
logical :: ManualPumpPower
logical :: Valve1
logical :: Valve2
logical :: Valve3
logical :: Valve4
logical :: Valve5
! logical :: ManualPumpPower
! logical :: Valve1
! logical :: Valve2
! logical :: Valve3
! logical :: Valve4
! logical :: Valve5
End type PumpSpecificationType
! Type(PumpSpecificationType)::PumpsSpecification


+ 6
- 6
CSharp/BasicInputs/RigSpecifications/CPumpsVariables.i90 View File

@@ -38,12 +38,12 @@ module CPumpsVariables
logical :: MudPump2ReliefValveIsSet
logical :: CementPumpReliefValveIsSet
logical :: ManualPumpPower
logical :: Valve1
logical :: Valve2
logical :: Valve3
logical :: Valve4
logical :: Valve5
! logical :: ManualPumpPower
! logical :: Valve1
! logical :: Valve2
! logical :: Valve3
! logical :: Valve4
! logical :: Valve5
End type PumpSpecificationType
! Type(PumpSpecificationType)::PumpsSpecification


+ 16
- 0
CSharp/BasicInputs/RigSpecifications/CRigSizeVariables.i90 View File

@@ -0,0 +1,16 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/RigSpecifications/CRigSizeVariables.f90"
module CRigSizeVariables
implicit none
public
!constants
integer :: Convensional_RigSize = 0
! variables
Type:: RigSizeType
integer :: RigType
real(8) :: CrownHeight
real(8) :: MonkeyBoandHeight
real(8) :: RigFloorHeight
End type RigSizeType
Type(RigSizeType)::RigSize
end module CRigSizeVariables

+ 8
- 5
CSharp/BasicInputs/WellProfile/CPathGeneration.f90 View File

@@ -9,7 +9,7 @@ module CPathGeneration
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: ppath,pitems,pdp,p
type(json_value),pointer :: ppath,pitems,p
integer::i,n
! 1. create new node
@@ -47,19 +47,22 @@ module CPathGeneration
use json_module,IK =>json_ik
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p,pitems,pitem,pval,pbit,dpoints,dpoint
type(json_value),pointer :: p,pitems,pitem,pval
logical::is_found
type(CStringItem) :: item
integer::i,n_children
CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val
call json%get(parent,'Path',p)
call json%get(p,'Items',pitems)
call json%info(pitems, n_children=n_children)
if (.not. allocated(data%Configuration%Path%Items) .or. size(data%Configuration%Path%Items)/=n_children) then
if (.not. allocated(data%Configuration%Path%Items)) then
ALLOCATE(data%Configuration%Path%Items(n_children))
endif
if(size(data%Configuration%Path%Items)/=n_children) then
DEALLOCATE(data%Configuration%Path%Items)
ALLOCATE(data%Configuration%Path%Items(n_children))
endif
do i=1,n_children
call json%get_child(pitems, i, pitem, found=is_found)
call json%get(pitem,"HoleType",pval)


+ 8
- 5
CSharp/BasicInputs/WellProfile/CPathGeneration.i90 View File

@@ -10,7 +10,7 @@ module CPathGeneration

type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: ppath,pitems,pdp,p
type(json_value),pointer :: ppath,pitems,p
integer::i,n

! 1. create new node
@@ -48,19 +48,22 @@ module CPathGeneration
use json_module,IK =>json_ik
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p,pitems,pitem,pval,pbit,dpoints,dpoint
type(json_value),pointer :: p,pitems,pitem,pval
logical::is_found
type(CStringItem) :: item
integer::i,n_children
CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val

call json%get(parent,'Path',p)
call json%get(p,'Items',pitems)
call json%info(pitems, n_children=n_children)

if (.not. allocated(data%Configuration%Path%Items) .or. size(data%Configuration%Path%Items)/=n_children) then
if (.not. allocated(data%Configuration%Path%Items)) then
ALLOCATE(data%Configuration%Path%Items(n_children))
endif
if(size(data%Configuration%Path%Items)/=n_children) then
DEALLOCATE(data%Configuration%Path%Items)
ALLOCATE(data%Configuration%Path%Items(n_children))
endif

do i=1,n_children
call json%get_child(pitems, i, pitem, found=is_found)
call json%get(pitem,"HoleType",pval)


+ 1
- 3
CSharp/BasicInputs/WellProfile/CPathGenerationVariables.f90 View File

@@ -20,9 +20,7 @@ module CPathGenerationVariables
Type :: PathGenerationType
integer :: ItemCount = 0
type(CPathGenerationItem), allocatable :: Items(:)
! integer :: DataPointsCount = 0
! type(CDataPointItem), allocatable :: DataPoints(:)
type(CPathGenerationItem), allocatable :: Items(:)
End type PathGenerationType
! Type(PathGenerationType)::PathGeneration


+ 1
- 3
CSharp/BasicInputs/WellProfile/CPathGenerationVariables.i90 View File

@@ -21,9 +21,7 @@ module CPathGenerationVariables

Type :: PathGenerationType
integer :: ItemCount = 0
type(CPathGenerationItem), allocatable :: Items(:)
! integer :: DataPointsCount = 0
! type(CDataPointItem), allocatable :: DataPoints(:)
type(CPathGenerationItem), allocatable :: Items(:)
End type PathGenerationType

! Type(PathGenerationType)::PathGeneration


+ 1
- 31
CSharp/Common/CCommon.f90 View File

@@ -15,36 +15,6 @@ module CCommon
integer function GetStandRack()
implicit none
GetStandRack = Common%StandRack
end function
! subroutine SetStandRack_WN(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: SetStandRack_WN
! !DEC$ ATTRIBUTES ALIAS: 'SetStandRack_WN' :: SetStandRack_WN
! implicit none
! integer, intent(in) :: v
! call SetStandRack(v)
! end subroutine
! ! Output routines
! logical function GetDrillWatchOperationMode()
! !DEC$ ATTRIBUTES DLLEXPORT :: GetDrillWatchOperationMode
! !DEC$ ATTRIBUTES ALIAS: 'GetDrillWatchOperationMode' :: GetDrillWatchOperationMode
! implicit none
! GetDrillWatchOperationMode = Common%DrillWatchOperationMode
! end function
! integer function GetStandRack_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: GetStandRack_WN
! !DEC$ ATTRIBUTES ALIAS: 'GetStandRack_WN' :: GetStandRack_WN
! implicit none
! GetStandRack_WN = Common%StandRack
! end function
end function
end module CCommon

+ 21
- 0
CSharp/Common/CCommon.i90 View File

@@ -0,0 +1,21 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/Common/CCommon.f90"
module CCommon
use CCommonVariables
implicit none
public
contains
! Input routines
subroutine SetStandRack(v)
implicit none
integer, intent(in) :: v
if(Common%StandRack == v) return
Common%StandRack = v
! call Common%OnStandRackChange%Run(v)
end subroutine

integer function GetStandRack()
implicit none
GetStandRack = Common%StandRack
end function
end module CCommon

+ 159
- 0
Common/DynamicRealArray.i90 View File

@@ -0,0 +1,159 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/Common/DynamicRealArray.f90"
module DynamicRealArray
implicit none
public
type, public :: DynamicRealArrayType
real, allocatable :: Array(:)
contains
procedure :: First => First
procedure :: Last => Last
procedure :: Length => Length
procedure :: Add => Add
procedure :: AddToFirst => AddToFirst
procedure :: AddTo => AddTo
procedure :: Remove => Remove
procedure :: Empty => Empty
end type DynamicRealArrayType
private::First,Last,Length
contains
real function First(this)
implicit none
class(DynamicRealArrayType), intent(in) :: this
if(allocated(this%Array) .and. size(this%Array) > 0) then
First = this%Array(1)
return
end if
First = 0
end function
real function Last(this)
implicit none
class(DynamicRealArrayType), intent(in) :: this
if(allocated(this%Array) .and. size(this%Array) > 0) then
Last = this%Array(size(this%Array))
return
end if
Last = 0
end function
integer function Length(this)
implicit none
class(DynamicRealArrayType), intent(in) :: this
if(allocated(this%Array)) then
Length = size(this%Array)
return
end if
Length = 0
end function
subroutine AddToFirst(this, value)
implicit none
class(DynamicRealArrayType), intent(inout) :: this
real, allocatable :: tempArr(:)
real, intent(in) :: value
integer :: i, isize
if(allocated(this%Array)) then
isize = size(this%Array)
allocate(tempArr(isize+1))
tempArr(1) = value
do i=2,isize+1
tempArr(i) = this%Array(i-1)
end do
deallocate(this%Array)
call move_alloc(tempArr, this%Array)
else
allocate(this%Array(1))
this%Array(1) = value
end if
end subroutine
subroutine AddTo(this, index, value)
implicit none
class(DynamicRealArrayType), intent(inout) :: this
real, allocatable :: tempArr(:)
integer, intent(in) :: index
real, intent(in) :: value
integer :: i, isize
if(index <= 0) return
if(index > size(this%Array)) then
call this%Add(value)
return
endif
if(allocated(this%Array)) then
isize = size(this%Array)
allocate(tempArr(isize+1))
tempArr(:index-1) = this%Array(:index-1)
tempArr(index) = value
tempArr(index+1:) = this%Array(index:)
deallocate(this%Array)
call move_alloc(tempArr, this%Array)
end if
end subroutine
subroutine Add(this, value)
implicit none
class(DynamicRealArrayType), intent(inout) :: this
real, allocatable :: tempArr(:)
real, intent(in) :: value
integer :: i, isize
if(allocated(this%Array)) then
isize = size(this%Array)
allocate(tempArr(isize+1))
do i=1,isize
tempArr(i) = this%Array(i)
end do
tempArr(isize+1) = value
deallocate(this%Array)
call move_alloc(tempArr, this%Array)
else
allocate(this%Array(1))
this%Array(1) = value
end if
end subroutine
subroutine Empty(this)
implicit none
class(DynamicRealArrayType), intent(inout) :: this
if(allocated(this%Array)) deallocate(this%Array)
end subroutine
subroutine Remove(this, index)
implicit none
class(DynamicRealArrayType), intent(inout) :: this
integer, intent(in) :: index
real, allocatable :: tempArr(:)
integer :: i
logical :: found
if(index <= 0 .or. index > size(this%Array)) return
if(.not.allocated(this%Array))return
allocate(tempArr(size(this%Array)-1))
found = .false.
do i=1, size(this%Array)
if(i==index) then
found = .true.
cycle
end if
if(found) then
tempArr(i-1) = this%Array(i)
else
tempArr(i) = this%Array(i)
endif
end do
deallocate(this%Array)
call move_alloc(tempArr, this%Array)
end subroutine
end module DynamicRealArray

+ 11
- 7
Redis/Redis_Interface.f90 View File

@@ -41,7 +41,6 @@ Module RedisInterface
type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue,jsonvalue2
type(json_core) :: jsoncore
logical :: is_found
character(len=:),allocatable :: password,address,datakey
character(len=:),allocatable::c_address,c_password,c_datakey
@@ -64,7 +63,7 @@ Module RedisInterface
c_password = password//c_null_char
c_address = address//c_null_char
call initConnection_C(c_address,port,c_password,c_datakey)
print *,"returned to initConnection"
! print *,"returned to initConnection"
END SUBROUTINE initConnection
SUBROUTINE setData(str)
@@ -96,14 +95,19 @@ Module RedisInterface
integer :: string_shape(1)
type(c_ptr) :: c_string
integer::l
! print *,"reading data (getData2)"
l = 30000
print *,"reading data l=",l
c_string = getData_C(l)
! string = c_str
print *,"data read. l=",l
! len = int(c_len,kind=kind(len))
string_shape(1) = int(l,kind=kind(integer))
if(.not. allocated(string)) allocate(character(l) :: string)
string_shape(1) = l!int(l,kind=kind(Integer))
if(.not. allocated(string)) then
print *,"allocate string"
allocate(character(l) :: string)
endif
call c_f_pointer(c_string, string, string_shape)
c_string=c_null_ptr
string = trim(string)
! print *,len_trim(string), "chars read."
! print *,string(1:l)
! getData2=string
@@ -120,7 +124,7 @@ Module RedisInterface
c_string = getData_C(l)
! string = c_str
! len = int(c_len,kind=kind(len))
string_shape(1) = int(l,kind=kind(integer))
string_shape(1) = l! int(l,kind=kind(integer))
if(.not. allocated(string)) allocate(character(l) :: string)
call c_f_pointer(c_string, string, string_shape)
c_string=c_null_ptr


+ 11
- 7
Redis/Redis_Interface.i90 View File

@@ -42,7 +42,6 @@ Module RedisInterface
type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue,jsonvalue2
type(json_core) :: jsoncore
logical :: is_found
character(len=:),allocatable :: password,address,datakey
character(len=:),allocatable::c_address,c_password,c_datakey

@@ -65,7 +64,7 @@ Module RedisInterface
c_password = password//c_null_char
c_address = address//c_null_char
call initConnection_C(c_address,port,c_password,c_datakey)
print *,"returned to initConnection"
! print *,"returned to initConnection"
END SUBROUTINE initConnection

SUBROUTINE setData(str)
@@ -97,14 +96,19 @@ Module RedisInterface
integer :: string_shape(1)
type(c_ptr) :: c_string
integer::l
! print *,"reading data (getData2)"
l = 30000
print *,"reading data l=",l
c_string = getData_C(l)
! string = c_str
print *,"data read. l=",l
! len = int(c_len,kind=kind(len))
string_shape(1) = int(l,kind=kind(integer))
if(.not. allocated(string)) allocate(character(l) :: string)
string_shape(1) = l!int(l,kind=kind(Integer))
if(.not. allocated(string)) then
print *,"allocate string"
allocate(character(l) :: string)
endif
call c_f_pointer(c_string, string, string_shape)
c_string=c_null_ptr
string = trim(string)
! print *,len_trim(string), "chars read."
! print *,string(1:l)
! getData2=string
@@ -121,7 +125,7 @@ Module RedisInterface
c_string = getData_C(l)
! string = c_str
! len = int(c_len,kind=kind(len))
string_shape(1) = int(l,kind=kind(integer))
string_shape(1) = l! int(l,kind=kind(integer))
if(.not. allocated(string)) allocate(character(l) :: string)
call c_f_pointer(c_string, string, string_shape)
c_string=c_null_ptr


+ 1
- 1
Redis/example_redis.c View File

@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hiredis.h"
#include "../include/hiredis.h"

#ifdef _MSC_VER
#include <winsock2.h> /* For struct timeval */


+ 14
- 8
Redis/redis_io.c View File

@@ -23,21 +23,23 @@ void initConnection(char *address, int *port,char * password,char *datakey)
printf("Can't allocate redis context\n");
}
}
printf("Connection Stablished to %s",address);
printf("Connection Stablished to %s\n",address);
if(strlen(password)>0)
{
redisReply *reply= redisCommand(context, "AUTH %s", password);
if (reply->type == REDIS_REPLY_ERROR) {
printf("Authentication failed.\n");
}
printf("Authentication is done.\n");
else {
printf("Authentication is done.\n");
}
freeReplyObject(reply);
}
// key = datakey;
key = malloc(sizeof(char) * (strlen(datakey)+1));
strcpy(key,datakey);
printf("datakey = %s with len %ld\n",datakey,strlen(datakey));
printf("...");
// printf("datakey = %s with len %ld\n",datakey,strlen(datakey));
// printf("...");
}
void setData(char *part, char *data)
@@ -51,15 +53,19 @@ void setData(char *part, char *data)
char *getData(int *len)
{
redisReply *reply;
// printf("reading data from redis(c function)\n");
printf("reading data from redis (key=%s)\n",key);
reply = redisCommand(context, "GET %s.in",key);
// printf("data read from redis: %s\n",reply->str);
printf("data read from redis: %ld chars\n",strlen(reply->str));
// printf("reply->str: %s\n",reply->str);
result = (char*) malloc(strlen(reply->str));
printf("len(reply->str): %ld\n",strlen(reply->str));
// result = (char*) malloc(strlen(reply->str));
result = (char*) malloc(*len);
printf("after malloc");
strcpy(result,reply->str);
*len = strlen(result);
printf("before free");
freeReplyObject(reply);
printf("after free");
return result;
}


BIN
View File


BIN
View File


BIN
View File


+ 21
- 22
Simulator.f90 View File

@@ -225,7 +225,7 @@ module Simulator
! type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue
type(json_core) :: jsoncore
logical :: is_found
! logical :: is_found
! character(len=:),allocatable :: password,address,datakey
! character(len=:),allocatable::c_address,c_password,c_datakey
@@ -280,28 +280,29 @@ module Simulator
subroutine read_configuration()
type(json_value),pointer :: jsonroot
type(json_value),pointer :: pval
call getData(redisOutput)
print *,len(redisOutput)," bytes read from redis"
! open(1,file="redisContent.json",status="REPLACE")
! write(1,"(A)") redisContent
! close(1)
call json%initialize()
call json%deserialize(jsonroot,redisOutput)
open(1,file="redisContent.json",status="REPLACE")
write(1,"(A)") redisOutput
close(1)
! call jsonfile%initialize()
! call json%initialize()
call jsonfile%initialize()
! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
! call jsonfile%json_file_get_root(jsonvalue)
call jsonfile%deserialize(redisOutput)
call jsonfile%json_file_get_root(jsonroot)
! call json%info(jsonvalue, n_children=n_children)
! print *,"n_children =",n_children
! call json%get(jsonroot,'status',pval)
! call json%get(pval,simulationStatus)
! call json%get(jsonroot,'speed',pval)
! call json%get(pval,simulationSpeed)
! if(simulationSpeed==0) simulationSpeed = 1
! msPerStep = 100/simulationSpeed
! call json%get(jsonroot,'endstep',pval)
! call json%get(pval,simulationEnd)
call json%get(jsonroot,'status',pval)
call json%get(pval,simulationStatus)
call json%get(jsonroot,'speed',pval)
call json%get(pval,simulationSpeed)
if(simulationSpeed==0) simulationSpeed = 1
msPerStep = 100/simulationSpeed
call json%get(jsonroot,'endstep',pval)
call json%get(pval,simulationEnd)
call ConfigurationFromJson(jsonroot)
! call WarningsFromJson(jsonroot)
! call ProblemsFromJson(jsonvalue)
@@ -319,12 +320,11 @@ module Simulator
! open(1,file="redisContent.json",status="REPLACE")
! write(1,"(A)") redisContent
! close(1)
call json%initialize()
call json%deserialize(jsonroot,redisOutput)
call jsonfile%initialize()
call jsonfile%deserialize(redisOutput)
! call jsonfile%initialize()
! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
! call jsonfile%json_file_get_root(jsonvalue)
call jsonfile%json_file_get_root(jsonroot)
! call json%info(jsonvalue, n_children=n_children)
! print *,"n_children =",n_children
call json%get(jsonroot,'status',pval)
@@ -788,7 +788,6 @@ module Simulator
!use this as a template
subroutine notificationsFromJson(parent)
type(json_value),pointer :: parent
!
! type(json_value),pointer :: p


+ 21
- 22
Simulator.i90 View File

@@ -226,7 +226,7 @@ module Simulator
! type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue
type(json_core) :: jsoncore
logical :: is_found
! logical :: is_found
! character(len=:),allocatable :: password,address,datakey
! character(len=:),allocatable::c_address,c_password,c_datakey

@@ -281,28 +281,29 @@ module Simulator

subroutine read_configuration()
type(json_value),pointer :: jsonroot
type(json_value),pointer :: pval
call getData(redisOutput)
print *,len(redisOutput)," bytes read from redis"
! open(1,file="redisContent.json",status="REPLACE")
! write(1,"(A)") redisContent
! close(1)
call json%initialize()
call json%deserialize(jsonroot,redisOutput)
open(1,file="redisContent.json",status="REPLACE")
write(1,"(A)") redisOutput
close(1)

! call jsonfile%initialize()
! call json%initialize()

call jsonfile%initialize()
! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
! call jsonfile%json_file_get_root(jsonvalue)
call jsonfile%deserialize(redisOutput)
call jsonfile%json_file_get_root(jsonroot)
! call json%info(jsonvalue, n_children=n_children)
! print *,"n_children =",n_children
! call json%get(jsonroot,'status',pval)
! call json%get(pval,simulationStatus)
! call json%get(jsonroot,'speed',pval)
! call json%get(pval,simulationSpeed)
! if(simulationSpeed==0) simulationSpeed = 1
! msPerStep = 100/simulationSpeed
! call json%get(jsonroot,'endstep',pval)
! call json%get(pval,simulationEnd)
call json%get(jsonroot,'status',pval)
call json%get(pval,simulationStatus)
call json%get(jsonroot,'speed',pval)
call json%get(pval,simulationSpeed)
if(simulationSpeed==0) simulationSpeed = 1
msPerStep = 100/simulationSpeed
call json%get(jsonroot,'endstep',pval)
call json%get(pval,simulationEnd)
call ConfigurationFromJson(jsonroot)
! call WarningsFromJson(jsonroot)
! call ProblemsFromJson(jsonvalue)
@@ -320,12 +321,11 @@ module Simulator
! open(1,file="redisContent.json",status="REPLACE")
! write(1,"(A)") redisContent
! close(1)
call json%initialize()
call json%deserialize(jsonroot,redisOutput)

call jsonfile%initialize()
call jsonfile%deserialize(redisOutput)
! call jsonfile%initialize()
! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
! call jsonfile%json_file_get_root(jsonvalue)
call jsonfile%json_file_get_root(jsonroot)
! call json%info(jsonvalue, n_children=n_children)
! print *,"n_children =",n_children
call json%get(jsonroot,'status',pval)
@@ -789,7 +789,6 @@ module Simulator

!use this as a template
subroutine notificationsFromJson(parent)

type(json_value),pointer :: parent
!
! type(json_value),pointer :: p


+ 32
- 14
Test/testJson.f90 View File

@@ -4,11 +4,12 @@ program testjson
use iso_c_binding, only: c_null_char,c_char
integer::n_children
logical :: is_found
character(len=:),allocatable::redisContent
character(len=100),allocatable::redisOutput
type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue,p
type(json_core) :: jsoncore,json
type(json_value),pointer :: jsonroot,pval
type(json_core) :: json
character(len=:),allocatable::name
integer::simulationStatus,simulationSpeed
! call initConnection("config-remote.json")
@@ -19,21 +20,38 @@ program testjson
! close(1)
! call jsoncore%initialize()
! call jsoncore%deserialize(jsonvalue,redisContent)
! ! call jsonfile%initialize()
! ! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
! ! call jsonfile%json_file_get_root(jsonvalue)
redisOutput = '{"status":1,"speed":10}'
print *,"redisOutput=",redisOutput
call jsonfile%initialize()
call jsonfile%deserialize(redisOutput)
! call jsonfile%get("speed",simulationSpeed,is_found)
! if ( .not. is_found ) print *,"speed Not Found"
! call jsonfile%get("status",simulationStatus,is_found)
! if ( .not. is_found ) print *,"status Not Found"
! call jsonfile%get(pval,simulationSpeed)
print *,"speed=",simulationSpeed
print *,"status=",simulationStatus
call jsonfile%json_file_get_root(jsonroot)
call json%get(jsonroot,'status',pval)
call json%get(pval,simulationStatus)
call json%get(jsonroot,'speed',pval)
call json%get(pval,simulationSpeed)
print *,"speed=",simulationSpeed
print *,"status=",simulationStatus
call json%destroy(jsonroot)
! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
! call jsonfile%json_file_get_root(jsonvalue)
! call jsoncore%info(jsonvalue, n_children=n_children)
! print *,"n_children =",n_children
! call jsoncore%info(jsonvalue, name=name)
! print *,"name = ",name
call json%initialize(allow_duplicate_keys=.false.)
call json%create_object(p,'') !create the root
call json%add(p,'year',1805) !add some data
call json%add(p,'year',2000) !add some data
call json%add(p,'value',1.0) !add some data
call json%print(p,'test.json') !write it to a file
call json%destroy(p) !cleanup
! call json%initialize(allow_duplicate_keys=.false.)
! call json%create_object(p,'') !create the root
! call json%add(p,'year',1805) !add some data
! call json%add(p,'year',2000) !add some data
! call json%add(p,'value',1.0) !add some data
! call json%print(p,'test.json') !write it to a file
! call json%destroy(p) !cleanup
end program testjson

+ 32
- 14
Test/testJson.i90 View File

@@ -5,11 +5,12 @@ program testjson
use iso_c_binding, only: c_null_char,c_char
integer::n_children
logical :: is_found
character(len=:),allocatable::redisContent
character(len=100),allocatable::redisOutput
type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue,p
type(json_core) :: jsoncore,json
type(json_value),pointer :: jsonroot,pval
type(json_core) :: json
character(len=:),allocatable::name
integer::simulationStatus,simulationSpeed


! call initConnection("config-remote.json")
@@ -20,21 +21,38 @@ program testjson
! close(1)
! call jsoncore%initialize()
! call jsoncore%deserialize(jsonvalue,redisContent)

! ! call jsonfile%initialize()
! ! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
! ! call jsonfile%json_file_get_root(jsonvalue)
redisOutput = '{"status":1,"speed":10}'
print *,"redisOutput=",redisOutput
call jsonfile%initialize()
call jsonfile%deserialize(redisOutput)
! call jsonfile%get("speed",simulationSpeed,is_found)
! if ( .not. is_found ) print *,"speed Not Found"
! call jsonfile%get("status",simulationStatus,is_found)
! if ( .not. is_found ) print *,"status Not Found"
! call jsonfile%get(pval,simulationSpeed)
print *,"speed=",simulationSpeed
print *,"status=",simulationStatus
call jsonfile%json_file_get_root(jsonroot)
call json%get(jsonroot,'status',pval)
call json%get(pval,simulationStatus)
call json%get(jsonroot,'speed',pval)
call json%get(pval,simulationSpeed)
print *,"speed=",simulationSpeed
print *,"status=",simulationStatus
call json%destroy(jsonroot)
! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
! call jsonfile%json_file_get_root(jsonvalue)

! call jsoncore%info(jsonvalue, n_children=n_children)
! print *,"n_children =",n_children
! call jsoncore%info(jsonvalue, name=name)
! print *,"name = ",name
call json%initialize(allow_duplicate_keys=.false.)
call json%create_object(p,'') !create the root
call json%add(p,'year',1805) !add some data
call json%add(p,'year',2000) !add some data
call json%add(p,'value',1.0) !add some data
call json%print(p,'test.json') !write it to a file
call json%destroy(p) !cleanup
! call json%initialize(allow_duplicate_keys=.false.)
! call json%create_object(p,'') !create the root
! call json%add(p,'year',1805) !add some data
! call json%add(p,'year',2000) !add some data
! call json%add(p,'value',1.0) !add some data
! call json%print(p,'test.json') !write it to a file
! call json%destroy(p) !cleanup

end program testjson

BIN
View File


+ 0
- 7
TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.f90 View File

@@ -1,22 +1,15 @@
subroutine TD_WellReadData
use SimulationVariables !@
use SimulationVariables !@
implicit none
Integer :: i
data%State%TD_WellGeneral%WellIntervalsCount = data%Configuration%Path%ItemCount + 1 ! +1 is belong to ROP hole
if (Allocated(data%State%TD_WellGeo)) deAllocate (data%State%TD_WellGeo)
Allocate (data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount))
!====================================================
! Set Well Geometry Data
!====================================================


+ 105
- 0
TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.i90 View File

@@ -0,0 +1,105 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.f90"
subroutine TD_WellReadData

use SimulationVariables !@
implicit none
Integer :: i
data%State%TD_WellGeneral%WellIntervalsCount = data%Configuration%Path%ItemCount + 1 ! +1 is belong to ROP hole
if (Allocated(data%State%TD_WellGeo)) deAllocate (data%State%TD_WellGeo)
Allocate (data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount))
!====================================================
! Set Well Geometry Data
!====================================================
data%State%TD_WellGeo(1)%HoleType = data%Configuration%Path%Items(1)%HoleType
data%State%TD_WellGeo(1)%StartAngle = 0.d0 ![rad]
data%State%TD_WellGeo(1)%EndAngle = data%Configuration%Path%Items(1)%FinalAngle*(pi/180.d0) ![rad]
data%State%TD_WellGeo(1)%IntervalLength= data%Configuration%Path%Items(1)%TotalLength ![ft]
!data%State%TD_WellGeo(1)%VerticalDepth = PathGenerations(1)%TotalVerticalDepth
data%State%TD_WellGeo(1)%TopDepth = 0.d0
data%State%TD_WellGeo(1)%DownDepth = data%Configuration%Path%Items(1)%MeasuredDepth
Do i=2,data%State%TD_WellGeneral%WellIntervalsCount-1
data%State%TD_WellGeo(i)%HoleType = data%Configuration%Path%Items(i)%HoleType
data%State%TD_WellGeo(i)%StartAngle = data%Configuration%Path%Items(i-1)%FinalAngle*(pi/180.d0)
data%State%TD_WellGeo(i)%EndAngle = data%Configuration%Path%Items(i)%FinalAngle*(pi/180.d0)
data%State%TD_WellGeo(i)%IntervalLength= data%Configuration%Path%Items(i)%TotalLength
!data%State%TD_WellGeo(i)%VerticalDepth = data%Configuration%Path%Items(i)%TotalVerticalDepth
data%State%TD_WellGeo(i)%TopDepth = data%Configuration%Path%Items(i-1)%MeasuredDepth
data%State%TD_WellGeo(i)%DownDepth = data%Configuration%Path%Items(i)%MeasuredDepth
!=====> Radius Of Curvature Calculation
if (data%State%TD_WellGeo(i)%HoleType/=0) then
data%State%TD_WellGeo(i)%RCurvature = ((data%State%TD_WellGeo(i)%IntervalLength)/abs(data%State%TD_WellGeo(i)%EndAngle-data%State%TD_WellGeo(i)%StartAngle))
end if
End Do
!=====> Set ROP Hole Data
data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%HoleType = 0 !Straight
data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%StartAngle = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount-1)%EndAngle
data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%EndAngle = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%StartAngle
data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength= 0.d0
!data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%VerticalDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount-1)%VerticalDepth
data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount-1)%DownDepth
data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth+data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength
!=====> Vertical Depth Calculation
if ( data%State%TD_WellGeo(1)%HoleType==0 ) then
data%State%TD_WellGeo(1)%VerticalDepth = data%State%TD_WellGeo(1)%IntervalLength*cos(data%State%TD_WellGeo(1)%StartAngle)
else if ( data%State%TD_WellGeo(1)%HoleType==1 ) then
data%State%TD_WellGeo(1)%VerticalDepth = (data%State%TD_WellGeo(1)%RCurvature*sin(abs(data%State%TD_WellGeo(1)%EndAngle)-abs(data%State%TD_WellGeo(1)%StartAngle))*cos(abs(data%State%TD_WellGeo(1)%StartAngle)))-(data%State%TD_WellGeo(1)%RCurvature*(1.-cos(abs(data%State%TD_WellGeo(1)%EndAngle)-abs(data%State%TD_WellGeo(1)%StartAngle)))*sin(abs(data%State%TD_WellGeo(1)%StartAngle)))
else if ( data%State%TD_WellGeo(1)%HoleType==2 ) then
data%State%TD_WellGeo(1)%VerticalDepth = (data%State%TD_WellGeo(1)%RCurvature*sin(abs(abs(data%State%TD_WellGeo(1)%EndAngle)-abs(data%State%TD_WellGeo(1)%StartAngle)))*cos(abs(data%State%TD_WellGeo(1)%StartAngle)))+(data%State%TD_WellGeo(1)%RCurvature*(1.-cos(abs(abs(data%State%TD_WellGeo(1)%EndAngle)-abs(data%State%TD_WellGeo(1)%StartAngle))))*sin(abs(data%State%TD_WellGeo(1)%StartAngle)))
End if
Do i= 2,data%State%TD_WellGeneral%WellIntervalsCount
if ( data%State%TD_WellGeo(i)%HoleType==0 ) then
data%State%TD_WellGeo(i)%VerticalDepth = data%State%TD_WellGeo(i-1)%VerticalDepth+data%State%TD_WellGeo(i)%IntervalLength*cos(data%State%TD_WellGeo(i)%StartAngle)
else if ( data%State%TD_WellGeo(i)%HoleType==1 ) then
data%State%TD_WellGeo(i)%VerticalDepth = data%State%TD_WellGeo(i-1)%VerticalDepth+(data%State%TD_WellGeo(i)%RCurvature*sin(abs(data%State%TD_WellGeo(i)%EndAngle)-abs(data%State%TD_WellGeo(i)%StartAngle))*cos(abs(data%State%TD_WellGeo(i)%StartAngle)))-(data%State%TD_WellGeo(i)%RCurvature*(1.-cos(abs(data%State%TD_WellGeo(i)%EndAngle)-abs(data%State%TD_WellGeo(i)%StartAngle)))*sin(abs(data%State%TD_WellGeo(i)%StartAngle)))
else if ( data%State%TD_WellGeo(i)%HoleType==2 ) then
data%State%TD_WellGeo(i)%VerticalDepth = data%State%TD_WellGeo(i-1)%VerticalDepth+(data%State%TD_WellGeo(i)%RCurvature*sin(abs(abs(data%State%TD_WellGeo(i)%EndAngle)-abs(data%State%TD_WellGeo(i)%StartAngle)))*cos(abs(data%State%TD_WellGeo(i)%StartAngle)))+(data%State%TD_WellGeo(i)%RCurvature*(1.-cos(abs(abs(data%State%TD_WellGeo(i)%EndAngle)-abs(data%State%TD_WellGeo(i)%StartAngle))))*sin(abs(data%State%TD_WellGeo(i)%StartAngle)))
End if
End Do
!Do i=1,data%State%TD_WellGeneral%WellIntervalsCount
! print*, 'data%State%TD_WellGeo(i)%TopDepth=' , i , data%State%TD_WellGeo(i)%TopDepth
! print*, 'data%State%TD_WellGeo(i)%DownDepth=' , i , data%State%TD_WellGeo(i)%DownDepth
! print*, 'data%State%TD_WellGeo(i)%HoleType=' , i , data%State%TD_WellGeo(i)%HoleType
! print*, 'data%State%TD_WellGeo(i)%RCurvature=' , i , data%State%TD_WellGeo(i)%RCurvature
! print*, 'data%State%TD_WellGeo(i)%EndAngle=' , i , data%State%TD_WellGeo(i)%EndAngle
! print*, 'data%State%TD_WellGeo(i)%StartAngle=' , i , data%State%TD_WellGeo(i)%StartAngle
! print*, 'data%State%TD_WellGeo(i)%VerticalDepth=' , i , data%State%TD_WellGeo(i)%VerticalDepth
!end do
!=====> Well Total Length Calculation
data%State%TD_WellGeneral%WellTotalLength = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth
data%State%TD_WellGeneral%WellTotalVerticalLength = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%VerticalDepth


end subroutine

+ 3
- 3
config-debug.json View File

@@ -1,8 +1,8 @@
{
"redis":{
"address":"127.0.0.1",
"port":6379,
"password":"",
"address":"aberama.iran.liara.ir",
"port":32815,
"password":"4YKFnubfFFjfh4yTK7b0Rg9X",
"datakey":"data"
},
"logging":5

BIN
View File


+ 37
- 33
redisContent.json View File

@@ -1,4 +1,8 @@
{
"status": 4,
"speed": 1,
"endstep": 10,
"step": 36,
"Configuration": {
"StringConfiguration": {
"StringConfigurationItems": [],
@@ -52,37 +56,37 @@
"StopPressure2": 0.0E+0
},
"BopStack": {
"AboveAnnularHeight": 0.1E+2,
"AboveAnnularHeight": 0.0E+0,
"AnnularPreventerClose": 0.0E+0,
"AnnularPreventerHeight": 0.10199999999999999E+2,
"AnnularPreventerHeight": 0.0E+0,
"AnnularPreventerOpen": 0.0E+0,
"AnnularStringDrag": 0.0E+0,
"BlindRamClose": 0.0E+0,
"BlindRamHeight": 0.16239999999999998E+2,
"BlindRamHeight": 0.0E+0,
"BlindRamOpen": 0.0E+0,
"ChokeClose": 0.0E+0,
"ChokeLineId": 0.0E+0,
"ChokeLineLength": 0.0E+0,
"ChokeOpen": 0.0E+0,
"GroundLevel": 0.3E+2,
"KillClose": 0.15E+1,
"KillHeight": 0.18800000000000001E+2,
"KillOpen": 0.15E+1,
"GroundLevel": 0.0E+0,
"KillClose": 0.0E+0,
"KillHeight": 0.0E+0,
"KillOpen": 0.0E+0,
"LowerRamClose": 0.0E+0,
"LowerRamHeight": 0.21350000000000001E+2,
"LowerRamHeight": 0.0E+0,
"LowerRamOpen": 0.0E+0,
"RamStringDrag": 0.0E+0,
"UpperRamClose": 0.0E+0,
"UpperRamHeight": 0.14632E+2,
"UpperRamHeight": 0.0E+0,
"UpperRamOpen": 0.0E+0
},
"Hoisting": {
"DrillingLineBreakingLoadAbrasiveness": 0.0E+0,
"DriveTypeAbrasiveness": 0,
"KellyWeightAbrasiveness": 0.0E+0,
"NumberOfLineAbrasiveness": 0,
"TopDriveWeightAbrasiveness": 0.0E+0,
"TravelingBlockWeightAbrasiveness": 0.0E+0
"DrillingLineBreakingLoad": 0.0E+0,
"DriveType": 0,
"KellyWeight": 0.0E+0,
"NumberOfLine": 0,
"TopDriveWeight": 0.0E+0,
"TravelingBlockWeight": 0.0E+0
},
"Power": {
"CementPump": 0.0E+0,
@@ -102,7 +106,7 @@
"MudPump1Output": 0.0E+0,
"MudPump1OutputBblStroke": 0.0E+0,
"MudPump1Maximum": 0.0E+0,
"MudPump1ReliefValvePressure": 0.0E+0,
"MudPump1ReliefValvePressure": 0.6E+4,
"MudPump2LinerDiameter": 0.0E+0,
"MudPump2Stroke": 0.0E+0,
"MudPump2MechanicalEfficiency": 0.0E+0,
@@ -110,7 +114,7 @@
"MudPump2Output": 0.0E+0,
"MudPump2OutputBblStroke": 0.0E+0,
"MudPump2Maximum": 0.0E+0,
"MudPump2ReliefValvePressure": 0.0E+0,
"MudPump2ReliefValvePressure": 0.6E+4,
"CementPumpLinerDiameter": 0.0E+0,
"CementPumpStroke": 0.0E+0,
"CementPumpMechanicalEfficiency": 0.0E+0,
@@ -118,7 +122,7 @@
"CementPumpOutput": 0.0E+0,
"CementPumpOutputBblStroke": 0.0E+0,
"CementPumpMaximum": 0.0E+0,
"CementPumpReliefValvePressure": 0.0E+0,
"CementPumpReliefValvePressure": 0.6E+4,
"MudPump1ReliefValveIsSet": false,
"MudPump2ReliefValveIsSet": false,
"CementPumpReliefValveIsSet": false,
@@ -199,7 +203,7 @@
"RotaryGearsAbuse": false,
"HoistLineBreak": false,
"PartedDrillString": false,
"ActiveTankOverflow": false,
"ActiveTankOverflow": true,
"ActiveTankUnderVolume": false,
"TripTankOverflow": false,
"DrillPipeTwistOff": false,
@@ -769,9 +773,9 @@
"KillLineValve": 0.0E+0,
"ChokeLineValve": 0.0E+0,
"LowerRamsValve": 0.0E+0,
"ManifoldPressureGauge": 0.0E+0,
"AirSupplyPressureGauge": 0.0E+0,
"AccumulatorPressureGauge": 0.0E+0,
"ManifoldPressureGauge": 0.15E+4,
"AirSupplyPressureGauge": 0.12E+3,
"AccumulatorPressureGauge": 0.3E+4,
"AnnularPressureGauge": 0.0E+0,
"AnnularOpenLED": 0,
"AnnularCloseLED": 0,
@@ -785,10 +789,10 @@
"ChokeLineCloseLED": 0,
"LowerRamsOpenLED": 0,
"LowerRamsCloseLED": 0,
"AnnularStatus": 0.0E+0,
"UpperRamsStatus": 0.0E+0,
"MiddleRamsStatus": 0.0E+0,
"LowerRamsStatus": 0.0E+0
"AnnularStatus": 0.13625E+2,
"UpperRamsStatus": 0.13625E+2,
"MiddleRamsStatus": 0.13625E+2,
"LowerRamsStatus": 0.13625E+2
},
"ChokeControl": {
"ChokePanelPumpSelectorSwitch": 0,
@@ -804,7 +808,7 @@
"ChokePanelSPMCounter": 0.0E+0,
"ChokePanelTotalStrokeCounter": 0.0E+0,
"Choke1LED": 0,
"Choke2LED": 0
"Choke2LED": 1
},
"ChokeManifold": {
"ChokeManifoldValve1": false,
@@ -820,8 +824,8 @@
"ChokeManifoldValve11": false,
"ChokeManifoldValve12": false,
"ChokeManifoldValve13": false,
"HydraulicChock1": 0,
"HydraulicChock2": 0,
"HydraulicChock1": -2147483548,
"HydraulicChock2": -2147483548,
"HyChock1OnProblem": false,
"HyChock2OnProblem": false,
"LeftManChokeOnProblem": false,
@@ -918,12 +922,12 @@
"MP1CPSwitchT": 0,
"MP1CPSwitch": 0,
"MP1ThrottleUpdate": false,
"MP1Throttle": -0.1E+1,
"MP1Throttle": 0.0E+0,
"MP2SwitchI": 0,
"MP2SwitchT": false,
"MP2Switch": false,
"MP2ThrottleUpdate": false,
"MP2Throttle": -0.1E+1,
"MP2Throttle": 0.0E+0,
"DWSwitch": 0,
"DWThrottle": 0.0E+0,
"RTSwitch": 0,
@@ -997,7 +1001,7 @@
},
"Hook": {
"HookHeight_S": 0.0E+0,
"HookHeight": 0.0E+0
"HookHeight": 0.75E+2
},
"StandPipeManifold": {
"StandPipeManifoldValve1": false,
@@ -1030,7 +1034,7 @@
"SPM1": 0.0E+0,
"SPM2": 0.0E+0,
"CasingPressure": 0.0E+0,
"PercentFlow": 0.0E+0,
"PercentFlow": "NaN",
"PitGainLose": 0.0E+0,
"PitVolume": 0.0E+0,
"KillMudVolume": 0.0E+0,


+ 24
- 24
test.json View File

@@ -6,7 +6,7 @@
"StringConfiguration": {
"StringConfigurationItems": [
{
"ComponentLength": 0.88931816251424378E-322,
"ComponentLength": 0.83991159793011913E-322,
"ComponentType": 0,
"Grade": "A",
"LengthPerJoint": 0.0E+0,
@@ -43,19 +43,19 @@
},
"Formations": [
{
"Abrasiveness": 0.21312660155733048E-263,
"Drillablity": 0.6320758923451116E-66,
"PorePressureGradient": 0.28008646127460173E-84,
"Thickness": 0.65823145377002607E+181,
"ThresholdWeight": 0.19550125239880232E+209,
"Abrasiveness": 0.0E+0,
"Drillablity": 0.0E+0,
"PorePressureGradient": 0.0E+0,
"Thickness": 0.0E+0,
"ThresholdWeight": 0.0E+0,
"Top": 0.0E+0
},
{
"Abrasiveness": 0.43520275400635665E+252,
"Drillablity": 0.9083672029223863E+224,
"PorePressureGradient": 0.81573800331711587E-42,
"Thickness": 0.51434297357626681E+171,
"ThresholdWeight": 0.1490043928945281E+196,
"Abrasiveness": 0.0E+0,
"Drillablity": 0.0E+0,
"PorePressureGradient": 0.0E+0,
"Thickness": 0.0E+0,
"ThresholdWeight": 0.0E+0,
"Top": 0.1E+4
}
],
@@ -112,7 +112,7 @@
"KillHeight": 0.0E+0,
"KillOpen": 0.53049901345204898E-314,
"LowerRamClose": 0.23715151000379834E-321,
"LowerRamHeight": 0.11419335319803565E-315,
"LowerRamHeight": 0.54862156021258701E-316,
"LowerRamOpen": 0.98813129168249309E-323,
"RamStringDrag": 0.0E+0,
"UpperRamClose": 0.0E+0,
@@ -201,19 +201,19 @@
"HoleType": 0,
"Angle": 0.0E+0,
"Length": 0.1E+4,
"FinalAngle": 0.81573800331703431E-42,
"TotalLength": 0.25384625402140253E+266,
"MeasuredDepth": 0.85260404050988764E+248,
"TotalVerticalDepth": 0.13849770568415003E+220
"FinalAngle": 0.0E+0,
"TotalLength": 0.0E+0,
"MeasuredDepth": 0.0E+0,
"TotalVerticalDepth": 0.0E+0
},
{
"HoleType": 926036234,
"Angle": 0.73530327575511794E+224,
"HoleType": 0,
"Angle": 0.0E+0,
"Length": 0.2E+4,
"FinalAngle": 0.78365824094029884E+200,
"TotalLength": 0.38606650640394845E-85,
"MeasuredDepth": 0.10912776606995678E+276,
"TotalVerticalDepth": 0.57356744358002641E+170
"FinalAngle": 0.0E+0,
"TotalLength": 0.0E+0,
"MeasuredDepth": 0.0E+0,
"TotalVerticalDepth": 0.0E+0
}
]
},
@@ -240,7 +240,7 @@
"ActiveSettledContents": 0.0E+0,
"ActiveSettledContentsGal": 0.0E+0,
"ActiveTotalContents": 0.98813129168249309E-323,
"ActiveTotalContentsGal": 0.11419398560206232E-315,
"ActiveTotalContentsGal": 0.54862788425285377E-316,
"ActiveAutoDensity": false,
"InitialTripTankMudVolume": 0.0E+0,
"InitialTripTankMudVolumeGal": 0.53049901345204898E-314,
@@ -258,7 +258,7 @@
"PlugJets": {
"ProblemType": 2,
"StatusType": 0,
"Value": 0.11419398560206232E-315,
"Value": 0.54862788425285377E-316,
"DueValue": 0.27667676167109806E-321
},
"JetWashoutCount": 0,


+ 3
- 1
todo.txt View File

@@ -1 +1,3 @@
/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/Geology/CShoeVariables.f90
what is this???!!
Mud%ActiveMudVolumeGal
Mud%ActiveMudVolume

Loading…
Cancel
Save