psmile_transform_cell_cyclic_dble.F90
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #undef VERBOSE
00029 subroutine psmile_transform_cell_cyclic_dble (cell, cyclic_grid_extent, ierror)
00030
00031
00032
00033 use psmile_common, only : ch_id
00034 use psmile_grid
00035
00036
00037
00038 double precision, intent(in) :: cyclic_grid_extent
00039
00040
00041
00042 double precision, intent(inout) :: cell (4)
00043
00044
00045
00046
00047
00048
00049 integer, intent (out) :: ierror
00050
00051
00052
00053
00054 logical :: trans_req
00055
00056 double precision :: half_cyclic_grid_extent
00057
00058 double precision :: edge_length
00059
00060 integer :: i
00061
00062 integer :: index1, index2
00063
00064 #ifdef VERBOSE
00065 print 9990, trim(ch_id), cell
00066 call psmile_flushstd
00067 #endif /* VERBOSE */
00068
00069 ierror = 0
00070
00071 trans_req = .false.
00072 half_cyclic_grid_extent = cyclic_grid_extent / 2._psmile_float_kind
00073
00074 index2 = 4
00075
00076 do i = 1, 8
00077
00078
00079
00080 index1 = iand(ior(i, 1), 3)
00081 index2 = ieor(index2, 6)
00082
00083 edge_length = cell(index1) - cell(index2)
00084
00085 #if defined(DEBUG) && defined(VERBOSE)
00086 if (abs(edge_length) > half_cyclic_grid_extent) &
00087 print 9970, trim(ch_id), cell(index1), cell(index2)
00088 #endif
00089
00090
00091 do while (edge_length < - half_cyclic_grid_extent)
00092
00093 cell(index1) = cell(index1) + cyclic_grid_extent
00094
00095 edge_length = cell(index1) - cell(index2)
00096 enddo
00097
00098
00099 do while (edge_length > half_cyclic_grid_extent)
00100
00101
00102 cell(index2) = cell(index2) + cyclic_grid_extent
00103
00104
00105 edge_length = cell(index1) - cell(index2)
00106 enddo
00107
00108 enddo
00109
00110 #ifdef VERBOSE
00111 print 9991, trim(ch_id), cell
00112 print 9980, trim(ch_id), ierror
00113 call psmile_flushstd
00114
00115 9990 format (1x, a, ': psmile_transform_cell_cyclic_dble: cell in ', 4f8.2)
00116 9991 format (1x, a, ': psmile_transform_cell_cyclic_dble: cell out', 4f8.2)
00117 9980 format (1x, a, ': psmile_transform_cell_cyclic_dble: eof ierror =', i3)
00118 9970 format (1x, a, ': psmile_transform_cell_cyclic_dble: transforming edge: ', 4f8.2)
00119
00120 #endif /* VERBOSE */
00121
00122 end subroutine psmile_transform_cell_cyclic_dble