ITM Grid Service Library: Fortran 90
|
00001 program itm_grid_example5_1dstructured 00002 00003 !> This example program demonstrates how to use the general grid description 00004 !> to store a simple 2d structured grid and write some data given on it to the CPO. 00005 !> 00006 !> The focus of this example program is delegate as much work as possible onto the 00007 !> grid service library. This is the recommended way to use the general grid description. 00008 !> 00009 !> If you want to learn how to do everything manually, step-by-step, without hiding any 00010 !> complexity behind high-level calls, have a look at the file itm_grid_example1_2dstructured_manual.f90 00011 !> in this directory. 00012 !> 00013 !> The used grid is described in detail here on the ITM Documentation Website (https://www.efda-itm.eu/ITM/html/) 00014 !> Then go to IMP3 -> IMP3 general grid description & service library -> Example grids -> Example grid #1 00015 !> Direct link (might be broken): https://www.efda-itm.eu/ITM/html/imp3_gridexamples.html#imp3_gridexamples_5 00016 00017 use itm_types ! ITM standard Fortran data types, e.g. real(R8) 00018 use euITM_schemas ! ITM data structure/CPO definitions 00019 use euITM_routines ! ITM UAL routines 00020 use itm_grid_common ! ITM grid service library: constant definitions like COORDTYPE_R, COORDTYPE_Z 00021 use itm_grid_structured ! ITM grid service libary, routines for handling structured grids 00022 use itm_constants, pi => itm_pi 00023 00024 implicit none 00025 00026 ! parameters 00027 integer, parameter :: NPOINTR = 50 00028 00029 integer, parameter :: SHOTNUM = 9005 00030 integer, parameter :: RUNNUM = 0 00031 00032 real(R8) :: XMIN = 2*pi 00033 real(R8) :: XMAX = 2*pi + 2*pi 00034 00035 ! variables 00036 type (type_edge),pointer :: edgecpo(:) => null() 00037 integer :: idx 00038 integer :: i 00039 00040 real(R8), dimension(NPOINTR) :: x, y 00041 real(R8) :: dx 00042 00043 00044 ! === 1. Set up CPO === 00045 00046 allocate( edgecpo(1) ) 00047 allocate( edgecpo(1)%datainfo%dataprovider(1) ) 00048 edgecpo(1)%datainfo%dataprovider="IMP3" 00049 allocate( edgecpo(1)%codeparam%codename(1) ) 00050 edgecpo(1)%codeparam%codename(1)="itm_grid_example1_2dstructured_manual" 00051 edgecpo(1)%time = 0.0_R8 00052 00053 ! === 2. Set up grid === 00054 00055 dx = (XMAX - XMIN) / (NPOINTR-1) 00056 x = (/ ( XMIN + dx * i, i=0,NPOINTR-1) /) 00057 00058 call gridSetupStructuredSep( edgecpo(1)%grid, & 00059 & ndim = 1, & 00060 & c1 = COORDTYPE_R, & 00061 & x1 = x, & 00062 & id = '1d_structured' ) 00063 00064 ! === 3. Set up subgrid for 2d cells ("faces") === 00065 00066 ! Not necessary, a default set of subgrids is automatically created by gridSetupStructured. 00067 ! You can disable this behaviour by calling gridSetupStructuredSep with the optional 00068 ! argument createSubgrids = .false. 00069 ! 00070 ! The easiest way to manually create the subgrid for all (1,1) cells ("faces") is 00071 ! allocate(edgecpo(1)%subgrids(1)) 00072 ! call createSubGridForClass(edgecpo(1)%grid, edgecpo(1)%subgrids(1), (/ 1, 1 /), "Cells") 00073 00074 ! === 4. Write some fake scalar data to the edge cpo === 00075 00076 ! Make up some data 00077 00078 ! Write the data to the complexgrid_scalar data structure 00079 allocate(edgecpo(1)%fluid%ne%value(3)) 00080 y = (/ ( x(i), i=1,NPOINTR ) /) 00081 call gridStructWriteData1d( edgecpo(1)%grid, edgecpo(1)%fluid%ne%value(1), GRID_STRUCT_NODES, y ) 00082 y = (/ ( sin(x(i)), i=1,NPOINTR ) /) 00083 call gridStructWriteData1d( edgecpo(1)%grid, edgecpo(1)%fluid%ne%value(2), GRID_STRUCT_NODES, y ) 00084 y = (/ ( exp(x(i)), i=1,NPOINTR ) /) 00085 call gridStructWriteData1d( edgecpo(1)%grid, edgecpo(1)%fluid%ne%value(3), GRID_STRUCT_NODES, y ) 00086 00087 ! === 5. Write the edge CPO to the UAL === 00088 00089 write (*,*) "Example 5: writing to shot ", SHOTNUM, ", run ", RUNNUM 00090 call euitm_create( 'euitm', SHOTNUM, RUNNUM, 0, 0, idx) 00091 call euitm_put(idx, "edge", edgecpo) 00092 call euitm_close(idx) 00093 call euitm_deallocate(edgecpo) 00094 00095 end program itm_grid_example5_1dstructured