implicit real*8(a-h,o-z)
dimension x(10000000),y(1000000),z(1000000)
!下でヤング率ポアソン比設定
open(7,file='kou15.unv')
open(8,file='kou15.inp')
p=1.0d-4!荷重(MN)
ell=0.4d0!inpファイル内での梁の長さ(載荷節点用)
nsettensuu=4096!節点数を入力(Node)
nedgeyouso=180!1D(edges)要素の数の入力
nfaceyouso=1350!2D(faces)要素の数の入力
nvolumeyouso=3375!3D(volume)要素の数の入力
write(8,'("** 節点番号と座標")')
write(8,'("*NODE, NSET=Nall")')
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
read (7,'()') 
do i=1,nsettensuu    !節点数
read (7,*) nset,n1,n2,n3
read(7,*) x(i),y(i),z(i)
write(8,'(i6,a,1pe13.5,a,1pe13.5a,1pe13.5)') nset,',',x(i)/1.0d3&
&,',',y(i)/1.0d3,',',z(i)/1.0d3
end do
!ここまではうまく行く
write(8,'("** 要素番号とその要素を囲む節点番号")')
write(8,'("*ELEMENT, TYPE=C3D8, ELSET=Eall")')
read (7,'()') 
read (7,'()') 
read (7,'()') 
do i=1,nedgeyouso
read(7,*) nyou,n1,n2,n3,n4,n5
read(7,*) n6,n7,n8
read(7,*) n9,n10
end do
!ここまでおｋ
do i=1,nfaceyouso
read(7,*) nyou,n1,n2,n3,n4,n5
read(7,*) n6,n7,n8,n9
end do
!番号,1,2,3,4,5,6,7,8みたいに書くといいので
do i=1,nvolumeyouso
read(7,*) nyou,n1,n2,n3,n4,n5
read(7,*) nset1,nset2,nset3,nset4,nset5,nset6,nset7,nset8
write(8,*) nyou-nfaceyouso-nedgeyouso,',',nset1,',',nset2,&
&',',nset3,',',nset4,',',nset5,',',nset6,&
&',',nset7,',',nset8
end do
close(7)
!write(8,'("** 要素グループここまで")')
!write(8,'("** 拘束節点を以下に挿入")')
write(8,'("*NSET,NSET=kousoku")')
do i=1,nsettensuu    !節点数
if (-0.0001<z(i).and.z(i)<0.0001) then
write(8,*) i,','
end if
end do
write(8,'("** 拘束節点ここまで")')
write(8,'("** 載荷節点を以下に挿入")')
write(8,'("*NSET,NSET=saika")')
nsaikasettensuu=0
do i=1,nsettensuu    !節点数
if (ell-0.00002<z(i)/1.0d3.and.z(i)/1.0d3<ell+0.00002) then!片持ち梁の端っこのz座標を条件にする
write(8,*) i,','
nsaikasettensuu=nsaikasettensuu+1
end if
end do
write(8,'("** 拘束節点ここまで")')
write(8,'("** 載荷条件を以下に挿入")')
write(8,'("** 載荷条件ここまで")')
write(8,'("** 材料の設定")')
write(8,'("*MATERIAL,NAME=EL")')
write(8,'("*ELASTIC")')
write(8,'("206.0d3,0.3")')  !ヤング率(MPa), ポアソン比
write(8,'("*SOLID SECTION,ELSET=Eall,MATERIAL=EL")')
write(8,'("*STEP")')
write(8,'("*STATIC,SOLVER=SPOOLES")')
write(8,'("** 拘束条件を以下に挿入")')
write(8,'("*BOUNDARY")')
write(8,'("kousoku,1,3")')
write(8,'("** 拘束条件ここまで")')
write(8,'("** 載荷条件を以下に挿入")')
write(8,'("*CLOAD")')
! "saika"で定義した節点の2(y)方向にp/載荷節点数を載荷
write(8,'(A,a,i6,a,1pe13.5)')'saika',',',2,',',p/nsaikasettensuu
write(8,'("** 載荷条件ここまで")')
write(8,'("** 出力の設定")')
write(8,'("*NODE PRINT,NSET=saika")')
write(8,'("U")')
write(8,'("*EL PRINT,ELSET=Eall")')
write(8,'("S")')
write(8,'("*NODE FILE")')
write(8,'("U")')
write(8,'("*EL FILE,POSITION=AVERAGED AT NODES")')
write(8,'("S")')
write(8,'("*END STEP")')
close(8)
end
