implicit real*8 (a-h, o-z)
dimension o(3000000),p(3000000),q(3000000),&
&x(3000000),y(3000000),z(3000000),&
&         mesh(1000000,11),narabi(10000,10000)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!1個目のsalomeのデータ
read*, nset !節点数の読み込み
do i=1,nset
read*, mesh(i,5),x(i),y(i),z(i)!各節点の座標値の読み込み
end do
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
read*, nyou !エレメント数の読み込み
do i=1,nyou
read*, mesh(i,1),mesh(i,2),mesh(i,3),mesh(i,4)!各エレメントの読み込み
end do
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!
!
!2個目のsalomeのデータ
!read*, nset2 !節点数の読み込み
!do i=1,nset2
!read*, mesh(i,6),o(i),p(i),q(i)!各節点の座標値の読み込み
!end do
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!read*, nyou2 !エレメント数の読み込み
!do i=1,nyou2
!read*, mesh(i,8),mesh(i,9),mesh(i,10),mesh(i,11)!各エレメントの読み込み
!end do
!
!
!
print'("** salomeのdatファイルをccxのC3D4要素inp化")'
print'("**")'
print'("*NODE, NSET=Nall")'
do i=1,nset
print *,mesh(i,5),",",x(i),",",y(i),",",z(i)
end do 
!do i=1,nset2
!print *,mesh(i,6)+nset,",",o(i),",",p(i),",",q(i)
!end do

print'("*ELEMENT, TYPE=C3D4, ELSET=zen")'
do i=1,nyou
print *,i,",",mesh(i,1),",",mesh(i,3),",",mesh(i,2),",",mesh(i,4)
end do

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!円の部分
print'("*ELEMENT, TYPE=C3D4, ELSET=soko")'
print'(i6,a)',3711,','
print'(i6,a)',3834,','
print'(i6,a)',4161,','
print'(i6,a)',12243,','
print'(i6,a)',15565,','
print'(i6,a)',16272,','
print'(i6,a)',19246,','
print'(i6,a)',25370,','
print'(i6,a)',25382,','
print'(i6,a)',31137,','
print'(i6,a)',46401,','
print'(i6,a)',47792,','
print'(i6,a)',54887,','
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!拘束の条件
print'("*NSET,NSET=FIX")'
print'("** ここに拘束したい節点番号とコンマを1行ずつ並べる")'
print'("** 例えば拘束節点の番号")'
!!ホゾの部分
!do i=181,186
!print'(i6,a)',i,','
!end do
!do i=5517,5520
!print'(i6,a)',i,','
!end do
print'(i6,a)',1,','
!print'(i6,a)',199,','
!print'(i6,a)',200,','
!print'(i6,a)',201,','
!print'(i6,a)',14741,','
print'("** みたいに")'
print'("*BOUNDARY")'
print'("** 以下のFIX,に続けて拘束変位1=x,2=y,3=zをコンマ区切りで")'
print'("FIX,1,3")'

!!!拘束の条件2
print'("*NSET,NSET=FIT")'
print'("** ここに拘束したい節点番号とコンマを1行ずつ並べる")'
print'("** 例えば拘束節点の番号")'
!!立方体の面の部分
do i=2004,2876
print'(i6,a)',i,','
end do
!!立方体のエッジの部分
do i=29,47
print'(i6,a)',i,','
end do
do i=124,142
print'(i6,a)',i,','
end do
do i=143,161
print'(i6,a)',i,','
end do
do i=162,180
print'(i6,a)',i,','
end do
print'(i6,a)',1,','
print'(i6,a)',3,','
print'(i6,a)',6,','
print'(i6,a)',7,','
!print'(i6,a)',305,','
print'("** みたいに")'
print'("*BOUNDARY")'
print'("** 以下のFIT,に続けて拘束変位1=x,2=y,3=zをコンマ区切りで")'
print'("FIT,1")'
print'("FIT,3")'

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!ヤング率について
print'("*MATERIAL,NAME=WOOD1")'
print'("*ELASTIC")'
e=8.5d3 ! ヤング率(MPa)
poi=0.4   !  ポアソン比
print*, e,',',poi

!print'("*MATERIAL,NAME=WOOD2")'
!print'("*ELASTIC")'
!e=6d3 ! ヤング率(MPa)
!poi=0.4   !  ポアソン比
!print*, e,',',poi

print'("*SOLID SECTION, ELSET=zen, MATERIAL=WOOD1")'
!print'("*SOLID SECTION, ELSET=kaba, MATERIAL=WOOD2")'

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!載荷条件
print'("*NSET,NSET=SAIKA")'
print'("** ここに載荷したい節点番号とコンマを1行ずつ並べる")'
print'("** 例えば載荷節点の番号")'

!!立方体の面の部分
!do i=1124,2003
!print'(i6,a)',i,','
!end do
!!立方体のエッジの部分
!do i=10,28
!print'(i6,a)',i,','
!end do
!do i=86,104
!print'(i6,a)',i,','
!end do
!do i=105,123
!print'(i6,a)',i,','
!end do
!do i=124,142
!print'(i6,a)',i,','
!end do
print'(i6,a)',8,','
!print'(i6,a)',2,','
!print'(i6,a)',5,','
!print'(i6,a)',6,','
!print'(i6,a)',305,','
print'(i6,a)',5519,','
!print'(i6,a)',2370,','

print'("** みたいに")'
print'("*STEP")'
print'("*STATIC,SOLVER=SPOOLES")'
print'("*CLOAD")'
!P=1.d-6 !載荷荷重(MN)
!nsaika=972 !載荷節点数
print'("** 以下のSAIKAに続けて載荷方向、載荷荷重を書く")'
print'("** 例えば載荷方向、載荷荷重がr/nsaikaなら")'
r=1.d-3 !載荷荷重(MN)
nsaika=960 !載荷節点数
write(*,*)'SAIKA,2,',r/nsaika
print'("*NODE PRINT,NSET=Nall")'
print'("U")'
print'("*EL PRINT,ELSET=Eall")'
print'("S")'
print'("*NODE FILE")'
print'("U")'
print'("*EL FILE,POSITION=AVERAGED AT NODES")'
print'("S")'
print'("*END STEP")'
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
open(8,file='ble6ccx.obj')
write(8,'("3DG1")')
write(8,*) nset+1
do i=0,nset
write(8,*) x(i),y(i),z(i)
end do
!
do i=1,nyou
write(8,*) 6,mesh(i,1),mesh(i,2),mesh(i,3),mesh(i,4)&
&              ,mesh(i,5),mesh(i,6),' ','0xcccccc'
end do
!
end
