ITM Grid Service Library: Fortran 90
|
00001 module itm_grid_examples 00002 00003 use itm_types 00004 use euITM_schemas ! IGNORE 00005 use euITM_routines ! IGNORE 00006 use itm_grid 00007 use itm_grid_structured 00008 use itm_grid_helper 00009 00010 implicit none 00011 00012 integer, parameter :: TEST1_SHOT = 9001 00013 integer, parameter :: TEST1_RUN = 1 00014 integer, parameter :: TEST1_TIME = 0.0 00015 00016 contains 00017 00018 ! Example 1: 2d structured grid 00019 00020 !> Example routine that assembles a 2d grid consisting of two 1d spaces 00021 function example_2d() result( grid ) 00022 type(type_complexgrid) :: grid 00023 00024 ! internal 00025 integer, parameter :: NPOINTR = 6 00026 integer, parameter :: NPOINTZ = 5 00027 00028 integer :: i 00029 00030 call gridSetupStructuredSep( grid, & 00031 & ndim = 2, & 00032 & c1 = COORDTYPE_R, & 00033 & x1 = (/ ( 1.0_R8 * i, i=0,NPOINTR-1) /), & 00034 & c2 = COORDTYPE_Z, & 00035 & x2 = (/ ( 0.5_R8 * i, i=0,NPOINTZ-1) /),& 00036 & id = '2d_structured' ) 00037 00038 call gridSanityCheck( grid, doStop = .false. ) 00039 00040 end function example_2d 00041 00042 00043 !!$ subroutine itm_grid_write_example_2d 00044 !!$ 00045 !!$ ! variables 00046 !!$ type (type_edge),pointer :: edgecpo(:) => null() 00047 !!$ integer :: idx 00048 !!$ 00049 !!$ ! internal 00050 !!$ integer, parameter :: NSPC = 2 00051 !!$ integer, parameter :: NDIM = 1 00052 !!$ integer, parameter :: NPOINTR = 6 00053 !!$ integer, parameter :: NPOINTZ = 5 00054 !!$ 00055 !!$ integer :: ir, iz 00056 !!$ real(R8) :: nodeData(NPOINTR, NPOINTZ), cellData(NPOINTR - 1, NPOINTZ - 1) 00057 !!$ 00058 !!$ ! set up cpo 00059 !!$ allocate( edgecpo(1) ) 00060 !!$ call setupEdgeCPO( edgecpo(1) ) 00061 !!$ 00062 !!$ ! set up grid 00063 !!$ edgecpo(1)%grid = example_2d() 00064 !!$ 00065 !!$ ! Write some fake data to CPO. 00066 !!$ allocate(edgecpo(1)%fluid%ne%value(4)) 00067 !!$ 00068 !!$ do ir = 1, NPOINTR 00069 !!$ nodeData(ir,:) = ir 00070 !!$ end do 00071 !!$ call gridStructWriteData2d( edgecpo(1)%grid, edgecpo(1)%fluid%ne%value(1), GRID_STRUCT_NODES, nodeData ) 00072 !!$ 00073 !!$ do ir = 1, NPOINTR - 1 00074 !!$ cellData(ir, :) = ir 00075 !!$ enddo 00076 !!$ call gridStructWriteData2d( edgecpo(1)%grid, edgecpo(1)%fluid%ne%value(2), GRID_STRUCT_FACES, cellData ) 00077 !!$ 00078 !!$ do iz = 1, NPOINTZ - 1 00079 !!$ cellData(:, iz) = iz 00080 !!$ enddo 00081 !!$ call gridStructWriteData2d( edgecpo(1)%grid, edgecpo(1)%fluid%ne%value(3), GRID_STRUCT_FACES, cellData ) 00082 !!$ 00083 !!$ do ir = 1, NPOINTR - 1 00084 !!$ do iz = 1, NPOINTZ - 1 00085 !!$ cellData(ir, iz) = ir * iz 00086 !!$ enddo 00087 !!$ enddo 00088 !!$ call gridStructWriteData2d( edgecpo(1)%grid, edgecpo(1)%fluid%ne%value(4), GRID_STRUCT_FACES, cellData ) 00089 !!$ 00090 !!$ 00091 !!$ ! Write CPO to ual 00092 !!$ write (*,*) "Example 1: writing to shot ", TEST1_SHOT, ", run ", TEST1_RUN 00093 !!$ call euitm_create( 'euitm', TEST1_SHOT, TEST1_RUN, 0, 0, idx) 00094 !!$ call euitm_put(idx,"edge", edgecpo) 00095 !!$ call euitm_close(idx) 00096 !!$ call euitm_deallocate(edgecpo) 00097 !!$ 00098 !!$ end subroutine itm_grid_write_example_2d 00099 00100 00101 subroutine itm_grid_read_example_2d( edgecpo ) 00102 type(type_edge), intent(out) :: edgecpo 00103 00104 ! variables 00105 !type(type_complexgrid) :: grid 00106 type(type_edge),pointer :: ledgecpo(:) => null() 00107 integer :: idx 00108 00109 ! read cpo 00110 ! treename, shot, run 00111 call euitm_open( 'euitm', TEST1_SHOT, TEST1_RUN, idx ) 00112 call euitm_get( idx,"edge", ledgecpo ) 00113 00114 edgecpo = ledgecpo(1) 00115 00116 end subroutine itm_grid_read_example_2d 00117 00118 00119 end module itm_grid_examples