-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathmag.f90
More file actions
70 lines (49 loc) · 1.85 KB
/
Copy pathmag.f90
File metadata and controls
70 lines (49 loc) · 1.85 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
submodule (io) mag
use sanity_check, only : check_finite_mag
use pathlib, only : copyfile, mkdir
implicit none (type, external)
interface ! mag_*.f90
module subroutine output_magfields_hdf5(outdir,ymd,UTsec,Br,Btheta,Bphi)
character(*), intent(in) :: outdir
integer, intent(in) :: ymd(3)
real(wp), intent(in) :: UTsec
real(wp), dimension(:), intent(in) :: Br,Btheta,Bphi
end subroutine output_magfields_hdf5
module subroutine output_magfields_nc4(outdir,ymd,UTsec,Br,Btheta,Bphi)
character(*), intent(in) :: outdir
integer, intent(in) :: ymd(3)
real(wp), intent(in) :: UTsec
real(wp), dimension(:), intent(in) :: Br,Btheta,Bphi
end subroutine output_magfields_nc4
module subroutine output_magfields_raw(outdir,ymd,UTsec,Br,Btheta,Bphi)
character(*), intent(in) :: outdir
integer, intent(in) :: ymd(3)
real(wp), intent(in) :: UTsec
real(wp), dimension(:), intent(in) :: Br,Btheta,Bphi
end subroutine output_magfields_raw
end interface
contains
module procedure create_outdir_mag
! subroutine create_outdir_mag(outdir,fieldpointfile)
!! CREATES OUTPUT DIRECTORY FOR MAGNETIC FIELD CALCULATIONS
integer :: ierr
!NOTE HERE THAT WE INTERPRET OUTDIR AS THE BASE DIRECTORY CONTAINING SIMULATION OUTPUT
ierr = mkdir(outdir//'/magfields/')
! ierr = mkdir(outdir//'/magfields/input/')
! ierr = copyfile(fieldpointfile, outdir//'/magfields/input/magfieldpoints.dat')
end procedure create_outdir_mag
module procedure output_magfields
select case (out_format)
case ('dat')
call output_magfields_raw(outdir,ymd,UTsec,Br,Btheta,Bphi)
case ('h5')
call output_magfields_hdf5(outdir,ymd,UTsec,Br,Btheta,Bphi)
case ('nc')
call output_magfields_nc4(outdir,ymd,UTsec,Br,Btheta,Bphi)
case default
write(stderr,*) 'mag:output_magfields: unknown file format' // out_format
error stop 2
end select
call check_finite_mag(Br, Btheta, Bphi)
end procedure output_magfields
end submodule mag