Skip to content

Commit c8a9873

Browse files
authored
Merge pull request #8 from cd10kfsu/feature/cda/nc_string
Feature/cda/nc string
2 parents 9355e92 + 5d9705a commit c8a9873

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ config/env.sh sets the required environmental vars used by CMAKE.
9696
cmake .. -DBUILD_NC=ON -DBUILD_H5=on -DH5_VERSION_1_8=ON -DBUILD_FAST_IO=ON
9797
make; make test
9898
```
99+
4. Most common combination for Mac ARM (enable hdf5 (version>1.8) & nc, disable hdf4)
100+
```
101+
. ../config/env.gnu.mac-arm.sh && cmake .. -DBUILD_NC=ON -DBUILD_H4=OFF -DBUILD_H5=ON -DH5_VERSION_1_8=OFF -DBUILD_FAST_IO=ON && make && make test
102+
```

config/env.gnu.mac-arm.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
##/bin/bash -xe
2+
3+
#FC="mpif90"
4+
#FC_CFLAGS="-fp-model precise -O2"
5+
#FC_LFLAGS=""
6+
7+
#ARCHIVER=ar
8+
#ARCHIEVER_FLAGS= -crvs
9+
10+
# config for F90GIO installation
11+
#F90GIO_DIR=/Users/cda/Documents/work/lab/F90GIO
12+
#F90GIO_LIB_DIR=$(F90GIO_DIR)/lib
13+
#F90GIO_INCLUDE_DIR=$(F90GIO_DIR)/include
14+
15+
# config for Netcdf
16+
export NC_INCLUDE="/opt/homebrew/Cellar/netcdf-fortran/4.6.1/include"
17+
export NC_LIBS="-L/opt/homebrew/Cellar/netcdf-fortran/4.6.1/lib -lnetcdff -lnetcdf -lnetcdf"
18+
19+
# config for HDF4
20+
export H4_INCLUDE=""
21+
export H4_LIBS=`h4fc -show TESTSRC | awk -F"TESTSRC " '{print $2}'`
22+
23+
24+
# config for HDF5
25+
export H5_INCLUDE="/opt/homebrew/Cellar/hdf5/1.14.3_1/include"
26+
#"/opt/homebrew/Cellar/hdf5/1.14.3_1/include"
27+
export H5_LIBS="-L/opt/homebrew/Cellar/hdf5/1.14.3_1/lib -lhdf5_fortran -lhdf5"
28+
#/opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5_hl_fortran.a /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5_hl.a /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5_fortran.a /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5.a "
29+
30+
#-L/opt/homebrew/Cellar/hdf5/1.14.3_1/lib /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5_hl_fortran.a /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5_hl.a /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5_fortran.a /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5.a /opt/homebrew/lib/libsz.a -lz -ldl -lm"
31+
32+
33+
echo "====================================="
34+
echo " F90GIO configurations:"
35+
echo
36+
echo "NC_INCLUDE=$NC_INCLUDE"
37+
echo "NC_LIBS=$NC_LIBS"
38+
39+
echo "H4_INCLUDE=$H4_INCLUDE"
40+
echo "H4_LIBS=$H4_LIBS"
41+
42+
echo "H5_INCLUDE=$H5_INCLUDE"
43+
echo "H5_LIBS=$H5_LIBS"

libsrc/fast/nc/m_ncio.f90

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ MODULE m_ncio
4949

5050
! low-level Read 1D
5151
PUBLIC :: nc_rdvar1d_i1, nc_rdvar1d_i2, nc_rdvar1d_i4, nc_rdvar1d_r4, &
52-
nc_rdvar1d_r8
52+
nc_rdvar1d_r8, nc_rdvar1d_str
5353
! low-level Read 2D
5454
PUBLIC :: nc_rdvar2d_i1, nc_rdvar2d_i2, nc_rdvar2d_i4, nc_rdvar2d_r4, &
5555
nc_rdvar2d_r8
@@ -312,6 +312,15 @@ SUBROUTINE nc_rdvar1d_r8(fid, varname, varval)
312312
include "nc_rdvar.f90.inc"
313313
END SUBROUTINE
314314

315+
SUBROUTINE nc_rdvar1d_str(fid, varname, varval)
316+
IMPLICIT NONE
317+
INTEGER(i4),INTENT(IN) :: fid
318+
CHARACTER(*),INTENT(IN) :: varname
319+
CHARACTER(*), INTENT(INOUT) :: varval(:)
320+
include "nc_rdvar.f90.inc"
321+
END SUBROUTINE
322+
323+
315324

316325
!--------------------------------------------------------------------------------
317326
! write 1D
@@ -400,6 +409,7 @@ SUBROUTINE nc_rdvar2d_r8(fid, varname, varval)
400409
include "nc_rdvar.f90.inc"
401410
END SUBROUTINE
402411

412+
403413
!--------------------------------------------------------------------------------
404414
! write 2D
405415
!--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)