|
|
|
@ -65,40 +65,49 @@ MODULE flux_calculator_io
|
|
|
|
|
|
|
|
|
|
CALL hdlerr(NF90_CLOSE(nc), __LINE__ ) |
|
|
|
|
|
|
|
|
|
! most simple case: single model, single task -> use full grid |
|
|
|
|
|
|
|
|
|
IF (num_bottom_models == 1) THEN |
|
|
|
|
! most simple case: single model, single task -> use full grid |
|
|
|
|
IF (num_tasks_per_model(1) == 1) THEN |
|
|
|
|
num_grid_cells = 0 |
|
|
|
|
num_grid_cells(1,1) = grid_size_global |
|
|
|
|
grid_size = grid_size_global |
|
|
|
|
grid_offset = 0 |
|
|
|
|
! single model, several tasks -> use only portion of the full grid |
|
|
|
|
ELSEIF (num_tasks_per_model(1) > 1) THEN |
|
|
|
|
! intialize variables with dummy values |
|
|
|
|
num_grid_cells = 0 |
|
|
|
|
grid_size = 0 |
|
|
|
|
grid_offset = -1 |
|
|
|
|
! read task vector from exchange grid file |
|
|
|
|
ALLOCATE(task(grid_size_global)) |
|
|
|
|
CALL hdlerr(NF90_OPEN(grid_filename, NF90_NOWRITE, nc), __LINE__ ) |
|
|
|
|
CALL hdlerr( NF90_INQ_VARID(nc, 'task' , varid), __LINE__ ) ! get variable id |
|
|
|
|
CALL hdlerr( NF90_GET_VAR (nc, varid, task(:), [1], [grid_size_global]), __LINE__ ) ! get variable values |
|
|
|
|
CALL hdlerr(NF90_CLOSE(nc), __LINE__ ) |
|
|
|
|
! go through the task vector and check which portion this intance will handle |
|
|
|
|
DO i = 1, grid_size_global |
|
|
|
|
IF (task(i) == mype) THEN |
|
|
|
|
! count grid cells in this task |
|
|
|
|
grid_size = grid_size + 1 |
|
|
|
|
! find grid offset (first index of this task - 1) |
|
|
|
|
IF (grid_offset == -1) THEN |
|
|
|
|
grid_offset = i-1 |
|
|
|
|
ENDIF |
|
|
|
|
ENDIF |
|
|
|
|
ENDDO |
|
|
|
|
! task can also be empty |
|
|
|
|
IF (grid_size == 0 .OR. grid_offset == -1) THEN |
|
|
|
|
grid_size = 0 |
|
|
|
|
grid_offset = 0 |
|
|
|
|
ENDIF |
|
|
|
|
num_grid_cells(1,mype + 1) = grid_size |
|
|
|
|
WRITE(*,*) "grid_size: ", grid_size, " grid_offset: ", grid_offset |
|
|
|
|
! task vector is not needed anymore |
|
|
|
|
DEALLOCATE(task) |
|
|
|
|
ENDIF |
|
|
|
|
|
|
|
|
|
ELSE |
|
|
|
|
! this case is not yet implemented (but somehow prepared) |
|
|
|
|
WRITE(*,*) "Only one bottom model is currently supported!" |
|
|
|
|
ENDIF |
|
|
|
|
|
|
|
|
|