Changeset 3864 for palm/trunk/SOURCE/netcdf_data_input_mod.f90
- Timestamp:
- Apr 5, 2019 9:01:56 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/netcdf_data_input_mod.f90
r3855 r3864 25 25 ! ----------------- 26 26 ! $Id$ 27 ! get_variable_4d_to_3d_real modified to enable read in data of type 28 ! data(t,y,x,n) one timestep at a time + some routines made public 29 ! 30 ! 3855 2019-04-03 10:00:59Z suehring 27 31 ! Typo removed 28 32 ! … … 913 917 netcdf_data_input_interpolate, netcdf_data_input_offline_nesting, & 914 918 netcdf_data_input_surface_data, netcdf_data_input_topo, & 915 netcdf_data_input_var, get_attribute, get_variable, open_read_file 919 netcdf_data_input_var, get_attribute, get_variable, open_read_file, & 920 check_existence, inquire_num_variables, inquire_variable_names 916 921 917 922 … … 5557 5562 INTEGER(iwp) :: ke !< start index of 3rd dimension 5558 5563 INTEGER(iwp) :: ks !< end index of 3rd dimension 5559 5564 5560 5565 INTEGER(KIND=1), DIMENSION(:,:,:), ALLOCATABLE :: tmp !< temporary variable to read data from file according 5561 5566 !< to its reverse memory access … … 5566 5571 ! 5567 5572 !-- Inquire variable id 5568 nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) 5573 nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) 5569 5574 ! 5570 5575 !-- Check for collective read-operation and set respective NetCDF flags if … … 5573 5578 #if defined( __netcdf4_parallel ) 5574 5579 nc_stat = NF90_VAR_PAR_ACCESS (id, id_var, NF90_COLLECTIVE) 5575 #endif 5580 #endif 5576 5581 ENDIF 5577 5582 ! … … 5582 5587 nc_stat = NF90_GET_VAR( id, id_var, tmp, & 5583 5588 start = (/ is+1, js+1, ks+1 /), & 5584 count = (/ ie-is+1, je-js+1, ke-ks+1 /) ) 5585 5586 CALL handle_error( 'get_variable_3d_int8', 533, variable_name ) 5589 count = (/ ie-is+1, je-js+1, ke-ks+1 /) ) 5590 5591 CALL handle_error( 'get_variable_3d_int8', 533, variable_name ) 5587 5592 ! 5588 5593 !-- Resort data. Please note, dimension subscripts of var all start at 1. … … 5594 5599 ENDDO 5595 5600 ENDDO 5596 5601 5597 5602 DEALLOCATE( tmp ) 5598 5603 … … 5627 5632 INTEGER(iwp) :: ke !< start index of 3rd dimension 5628 5633 INTEGER(iwp) :: ks !< end index of 3rd dimension 5629 5634 5630 5635 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: tmp !< temporary variable to read data from file according 5631 5636 !< to its reverse memory access … … 5641 5646 !-- required. 5642 5647 IF ( collective_read ) THEN 5643 #if defined( __netcdf4_parallel ) 5648 #if defined( __netcdf4_parallel ) 5644 5649 nc_stat = NF90_VAR_PAR_ACCESS (id, id_var, NF90_COLLECTIVE) 5645 5650 #endif … … 5653 5658 start = (/ is+1, js+1, ks+1 /), & 5654 5659 count = (/ ie-is+1, je-js+1, ke-ks+1 /) ) 5655 5660 5656 5661 CALL handle_error( 'get_variable_3d_real', 534, variable_name ) 5657 5662 ! … … 5664 5669 ENDDO 5665 5670 ENDDO 5666 5671 5667 5672 DEALLOCATE( tmp ) 5668 5673 … … 5737 5742 ELSE 5738 5743 ! 5739 !-- Allocate temporary variable according to memory access on file.5740 ALLOCATE( tmp(is:ie,js:je,k1s:k1e,k2s:k2e) )5741 ! 5742 !-- Get variable5743 nc_stat = NF90_GET_VAR( id, id_var, tmp, 5744 !-- Allocate temporary variable according to memory access on file. 5745 ALLOCATE( tmp(is:ie,js:je,k1s:k1e,k2s:k2e) ) 5746 ! 5747 !-- Get variable 5748 nc_stat = NF90_GET_VAR( id, id_var, tmp, & 5744 5749 start = (/ is+1, js+1, k1s+1, k2s+1 /), & 5745 5750 count = (/ ie-is+1, je-js+1, & … … 5748 5753 CALL handle_error( 'get_variable_4d_real', 535, variable_name ) 5749 5754 ! 5750 !-- Resort data. Please note, dimension subscripts of var all start at 1.5755 !-- Resort data. Please note, dimension subscripts of var all start at 1. 5751 5756 DO i = is, ie 5752 5757 DO j = js, je … … 5758 5763 ENDDO 5759 5764 ENDDO 5760 5765 5761 5766 DEALLOCATE( tmp ) 5762 5767 ENDIF … … 5828 5833 ELSE 5829 5834 ! 5830 !-- Allocate temporary variable according to memory access on file.5835 !-- Allocate temporary variable according to memory access on file. 5831 5836 ALLOCATE( tmp(is:ie,js:je,ks:ke) ) 5832 5837 ! 5833 !-- Get variable5834 nc_stat = NF90_GET_VAR( id, id_var, tmp, 5835 start = (/ ns+1, is+1, js+1, ks+1 /),&5836 count = (/ 1, ie-is+1, je-js+1, ke-ks+1 /) )5837 5838 !-- Get variable 5839 nc_stat = NF90_GET_VAR( id, id_var, tmp, & 5840 start = (/ is+1, js+1, ks+1, ns+1 /),& 5841 count = (/ ie-is+1, je-js+1, ke-ks+1, 1 /) ) 5842 5838 5843 CALL handle_error( 'get_variable_4d_to_3d_real', 536, variable_name ) 5839 5844 ! 5840 !-- Resort data. Please note, dimension subscripts of var all start at 1.5841 DO i = is, ie 5845 !-- Resort data. Please note, dimension subscripts of var all start at 1. 5846 DO i = is, ie 5842 5847 DO j = js, je 5843 5848 DO k = ks, ke … … 5846 5851 ENDDO 5847 5852 ENDDO 5848 5853 5849 5854 DEALLOCATE( tmp ) 5850 5855 … … 5962 5967 CHARACTER(LEN=*) :: variable_name !< variable name 5963 5968 5964 INTEGER(iwp) :: ns !< start index for subdomain input along n dimension: ns coincides here with ne, since, we select only one value along the 1st dimension n 5969 INTEGER(iwp) :: ns !< start index for subdomain input along n dimension: 5970 !< ns coincides here with ne, since, we select only one 5971 !< value along the 1st dimension n 5965 5972 5966 5973 INTEGER(iwp) :: t !< index along t direction … … 5986 5993 ! 5987 5994 !-- Inquire variable id 5988 nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) 5995 nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) 5989 5996 ! 5990 5997 !-- Check for collective read-operation and set respective NetCDF flags if 5991 !-- required. 5998 !-- required. 5992 5999 IF ( collective_read ) THEN 5993 6000 nc_stat = NF90_VAR_PAR_ACCESS (id, id_var, NF90_COLLECTIVE) … … 6036 6043 ENDDO 6037 6044 6038 DEALLOCATE( tmp )6045 DEALLOCATE( tmp ) 6039 6046 6040 6047 ENDIF
Note: See TracChangeset
for help on using the changeset viewer.