-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathcond.f90
More file actions
72 lines (48 loc) · 1.99 KB
/
Copy pathcond.f90
File metadata and controls
72 lines (48 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
submodule (io) io_cond
!! output conductivity to file
use filesystem, only : is_dir, mkdir
use timeutils, only : date_filename
use mpimod, only : gather_send
use, intrinsic :: ieee_arithmetic, only : ieee_is_finite
implicit none (type, external)
interface !< cond_*.f90
module subroutine output_cond_root_hdf5(filename, sig0, sigP, sigH)
character(*), intent(in) :: filename
real(wp), dimension(:,:,:), intent(in) :: sig0, sigP, sigH
end subroutine output_cond_root_hdf5
end interface
contains
module procedure output_cond
!! A BASIC WRAPPER FOR THE ROOT AND WORKER OUTPUT FUNCTIONS
!! BOTH ROOT AND WORKERS CALL THIS PROCEDURE SO UNALLOCATED
!! VARIABLES MUST BE DECLARED AS ALLOCATABLE, INTENT(INOUT)
character(:), allocatable :: outdir_cond
outdir_cond = outdir // '/conductivity'
if(.not. is_dir(outdir_cond)) call mkdir(outdir_cond)
if (mpi_cfg%myid == 0) then
call output_cond_root(date_filename(outdir, ymd, UTsec), sig0, sigP, sigH, out_format)
else
call output_cond_workers(sig0, sigP, sigH)
end if
end procedure output_cond
subroutine output_cond_root(stem, sig0, sigP, sigH, out_format)
character(*), intent(in) :: stem, out_format
real(wp), dimension(:,:,:), intent(in) :: sig0, sigP, sigH
select case (out_format)
case ('h5')
call output_cond_root_hdf5(stem // ".h5", sig0, sigP, sigH)
case default
error stop 'io:cond:output_cond_root: unknown grid format' // out_format
end select
if(.not. all(ieee_is_finite(sig0))) error stop 'io:output_cond: non-finite sig0'
if(.not. all(ieee_is_finite(sigP))) error stop 'io:output_cond: non-finite sigP'
if(.not. all(ieee_is_finite(sigH))) error stop 'io:output_cond: non-finite sigH'
end subroutine output_cond_root
subroutine output_cond_workers(sig0, sigP, sigH)
!! SEND COMPLETE DATA FROM WORKERS TO ROOT PROCESS FOR OUTPUT.
real(wp), dimension(:,:,:), intent(in) :: sig0, sigP, sigH
call gather_send(sig0, tag%io_sig0)
call gather_send(sigP, tag%io_sigP)
call gather_send(sigH, tag%io_sigH)
end subroutine output_cond_workers
end submodule io_cond