Skip to content

Commit

Permalink
Version used for simulations documenting the framework submitted to G…
Browse files Browse the repository at this point in the history
…eoscientific Model Development.
  • Loading branch information
palderman committed Nov 5, 2020
1 parent 830ad43 commit 93abdf6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
32 changes: 27 additions & 5 deletions FlexibleIO/MPI/dssat_mpi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ module dssat_mpi
integer rank
integer,dimension(:),allocatable :: trtno
character(len=:),allocatable :: varlist
contains
procedure,nopass :: close => close_mpi_connection
end type mpi_connection_template

type,extends(mpi_connection_template) :: mpi_parent_type
Expand All @@ -29,6 +27,7 @@ module dssat_mpi
procedure :: receive_variable => receive_registered_variable
procedure :: receive_registries
procedure :: print_registries => print_mpi_parent_registries
procedure :: close => close_mpi_parent_connection
end type mpi_parent_type

type,extends(mpi_connection_template) :: mpi_child_type
Expand All @@ -42,6 +41,7 @@ module dssat_mpi
procedure :: connect => connect_to_parent
procedure :: send_registry => send_registry_from_child
procedure :: send_variable => send_registered_variable_from_child
procedure :: close => close_mpi_child_connection
end type mpi_child_type

type(mpi_parent_type) :: mpi_parent
Expand Down Expand Up @@ -96,13 +96,15 @@ subroutine spawn_dssat_children(self,n_children,trt_start,trt_end,rnmode,crop_co
allocate(self%children(n_children),&
self%trtno_range(2,n_children),&
self%cmds(n_children),&
self%args(n_children,1),&
self%args(n_children,2),&
self%np(n_children),&
self%info(n_children),&
self%errors(n_children))

self%cmds = cmd

self%args(:,2) = ' '

do while(.true.)
i = index(dssat_args,',')
if(i==0) exit
Expand Down Expand Up @@ -373,16 +375,36 @@ subroutine print_mpi_parent_registries(self)

end subroutine print_mpi_parent_registries

subroutine close_mpi_connection()
subroutine close_mpi_parent_connection(self)

use mpi

implicit none

integer ierr

class(mpi_parent_type) self

! call MPI_Barrier(self%inter_comm,ierr)

call MPI_Finalize(ierr)

end subroutine close_mpi_parent_connection

subroutine close_mpi_child_connection(self)

use mpi

implicit none

integer ierr

class(mpi_child_type) self

! call MPI_Barrier(self%parent,ierr)

call MPI_Finalize(ierr)

end subroutine close_mpi_connection
end subroutine close_mpi_child_connection

end module dssat_mpi
5 changes: 4 additions & 1 deletion FlexibleIO/MPI/run_mpi_dssat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ program run_mpi_dssat

call get_dssat_arg('--n_dssat',n_dssat)

if(ntrt < n_dssat) n_dssat = ntrt

call nc_filex%set_file_from_cmd_arg('--nc_filex')

call get_dssat_arg('--nc_out',out_file_name)
Expand All @@ -69,7 +71,8 @@ program run_mpi_dssat
call nc_filex%open()
call nc_filex%read('CR',trt_start,crop_code)

write(*,fmt="(a)",advance="no") " Spawning DSSAT worker processes..."
write(rank_buff,'(i3)') n_dssat
write(*,fmt="(a)",advance="no") " Spawning "//trim(adjustl(rank_buff))//" DSSAT worker processes..."
call mpi_parent%spawn_dssat_children(n_dssat,trt_start,trt_end,rnmode,&
crop_code,cmd,dssat_args,work_dir)
write(*,fmt="(a)") "done."
Expand Down
7 changes: 4 additions & 3 deletions FlexibleIO/NetCDF/read_nc_sim_sec.for
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ C=======================================================================
USE CsvOutput
use csm_io
use dssat_netcdf
use dssat_mpi
IMPLICIT NONE
SAVE

Expand Down Expand Up @@ -409,11 +410,11 @@ C
ENDIF
IDETR = UPCASE(IDETR)
IDETL = '0'
! IDETL = '0'
! Verbose output switch
IF (IDETL == '0') THEN
! VBOSE = zero, suppress all output except Summary and Evaluate
IDETS = 'Y'
if(.not.mpi_child%use_mpi) IDETS = 'Y'
IDETG = 'N'
IDETC = 'N'
IDETW = 'N'
Expand All @@ -422,7 +423,7 @@ C
IDETD = 'N'
IDETH = 'N'
IDETR = 'N'
IDETO = 'E'
if(.not.mpi_child%use_mpi) IDETO = 'E'
! Seasonal and spatial runs do not get evaluate file when IDETL=0
IF (INDEX('SN',RNMODE) > 0) IDETO = 'N'
ELSEIF (IDETL == 'A') THEN
Expand Down

0 comments on commit 93abdf6

Please sign in to comment.