module infin use globals implicit none contains ! populate `heatsink_design' based on the data in the design file subroutine load_heatsink_design use globals implicit none real (8), dimension (4) :: data_row ! each row in the design file consists of four real numbers integer :: i, y ! air is the default material heatsink_design = Air open (unit = 1, file = design_file, action = 'read') ! read each line of the file do while (.not. eof (1)) ! read rectangle corners from file read (1, *) data_row ! convert from mm to metres data_row = data_row / 1000 ! convert from metres to grid points data_row (1: 2) = data_row (1: 2) / delta + 1 data_row (3: 4) = ceiling (data_row (3: 4) / delta) ! fill rectangular prism with aluminium heatsink_design (data_row (1): data_row (3), :, data_row (2): data_row (4)) = Aluminium end do close (1) ! set the y-edges to be air (only applies to the first and last processes) if (mpi_cpu_id == 0) heatsink_design (:, 0, :) = Air if (mpi_cpu_id == mpi_cpu_count - 1) heatsink_design (:, grid_size / mpi_cpu_count + 1, :) = Air ! use special material type for aluminium touching the cpu do i = 1, Grid_size / mpi_cpu_count ! y co-ordinate corresponding to this grid point y = mpi_cpu_id * Grid_size / mpi_cpu_count + i ! if the x and y co-ordinates lie within the (2 cm)^2 chip, ! then set that grid point to `Aluminium_touching_cpu' instead of just `Aluminium' if ((Domain_size - Chip_size) / 2 / Delta + 1 <= y & .and. y <= Grid_size - (Domain_size - Chip_size) / 2 / Delta) then heatsink_design ((Domain_size - Chip_size) / 2 / Delta + 1: Grid_size - (Domain_size - Chip_size) / 2 / Delta, i, 1) = & Aluminium_touching_cpu end if end do end subroutine load_heatsink_design subroutine initial_state temp3d(:,:,:) = Air_temp_K !do i = 0, grid_size + 1 ! do k = 0, grid_size + 1 ! select case(heatsink_design(i,1,k)) ! case(Aluminium) ! case(Aluminium_touching_cpu) ! case(Air) ! end select ! end do !end do end subroutine initial_state subroutine finalise logical :: openfile ! test for file open character(14) :: filename14 ! 14 character filename integer :: i, j, k ! loop variable ! convert from Kelvin to Celsius ! and reset all air cells to the correct temperature. do i = 0, grid_size + 1 do k = 0, grid_size + 1 if (heatsink_design(i,1,k) == Air) then temp3d(i,:,k) = Air_temp_K end if temp3d(i,:,k) = temp3d(i,:,k) - Celsius_offset end do end do ! ! finish up run ! Output temperature to file ! write( filename14,'(a,i1)') 'sinkout.data-',mpi_cpu_id open(unit=10, file=filename14, action='write') write(10,'(1es12.4)') temp3d(:, :, :) close( unit = 10 ) end subroutine finalise end module infin