27 CHARACTER(len=40) :: filename_ctl, filename_atm, dirname
28 INTEGER(c_int) :: argc
32 TYPE(
met_t),
TARGET :: met0, met1
33 TYPE(
met_t),
POINTER :: met0p, met1p
35 REAL(real64),
DIMENSION(npp) :: dt
36 CHARACTER(len=32) :: arg
37 TYPE(c_ptr),
ALLOCATABLE,
DIMENSION(:) :: argv_ptrs
38 CHARACTER(len=32),
ALLOCATABLE,
DIMENSION(:),
TARGET :: tmp
42 argc = command_argument_count()
45 WRITE(*,*)
"Error: Give parameters: <dirlist> <ctl> <atm_in>"
49 ALLOCATE(tmp(argc), argv_ptrs(argc))
52 CALL get_command_argument(i, arg)
53 IF (len_trim(arg) == 0)
EXIT
54 tmp(i) = trim(arg)//c_null_char
55 argv_ptrs(i) = c_loc(tmp(i))
59 OPEN(10,file=tmp(1),iostat=stat)
61 WRITE(*,*)
"Error: Cannot open directory list!"
66 READ(10,
'(a)',
END=200) dirname
68 filename_ctl = trim(dirname)//
"/"//tmp(2)
69 filename_atm = trim(dirname)//
"/"//tmp(3)
72 CALL mptrac_read_ctl(trim(filename_ctl)//c_null_char, argc, argv_ptrs, ctl)
75 CALL mptrac_read_clim(ctl, clim)
78 CALL mptrac_read_atm(trim(filename_atm)//c_null_char, ctl, atm)
81 CALL mptrac_module_timesteps_init(ctl, atm)
86 CALL mptrac_get_met(ctl, clim, ctl%t_start, met0p, met1p)
90 DO WHILE (ctl%direction * (t - ctl%t_stop) < ctl%dt_mod)
93 IF (ctl%direction * (t - ctl%t_stop) > 0)
THEN
98 CALL mptrac_module_timesteps(ctl, met0, atm, dt, t)
100 IF (t .NE. ctl%t_start)
THEN
102 CALL mptrac_get_met(ctl, clim, t, met0p, met1p)
106 CALL mptrac_module_advect(ctl, met0, met1, atm, dt)
109 CALL mptrac_write_output(trim(dirname)//c_null_char, ctl, met0, met1, atm, t)
111 t = t + ctl%direction * ctl%dt_mod