fortran66のブログ

fortran について書きます。

【メモ帳】ZMQ atomic

atomic

api.zeromq.org

program atomic
    use :: m_zmq
    implicit none
    type(c_ptr) :: counter
    integer(c_int) :: k
    integer, target :: ic

    counter = zmq_atomic_counter_new()
    call c_f_pointer(counter, ic)
    print *, 'counter', ic
    print *, zmq_atomic_counter_value(counter)
    print *, zmq_atomic_counter_inc(counter)
    print *, zmq_atomic_counter_inc(counter)
    print *, zmq_atomic_counter_inc(counter)
    print *, zmq_atomic_counter_dec(counter)
    print *, zmq_atomic_counter_dec(counter)
    print *, zmq_atomic_counter_dec(counter)
    print *, zmq_atomic_counter_dec(counter)
    print *, zmq_atomic_counter_dec(counter)
    print *, zmq_atomic_counter_value(counter)
    call zmq_atomic_counter_set (counter, 2)
    print *, zmq_atomic_counter_value(counter)
    call zmq_atomic_counter_destroy(c_loc(counter))
end program atomic
 counter          13
           0
           0
           1
           2
           1
           1
           0
           1
           1
          -2
           2

cryptograph

api.zeromq.org

program test_z85
    use m_zmq
    implicit none
    character(41), target :: public_key, secret_key, derived_public
    integer(c_int) :: iret
    iret = zmq_curve_keypair(c_loc(public_key), c_loc(secret_key))
    print *, 'iret', iret
    print *, index(public_key, achar(0)), public_key
    print *, index(secret_key, achar(0)), secret_key

    iret = zmq_curve_public(c_loc(derived_public), c_loc(secret_key))
    print *, 'iret', iret
    print *, index(derived_public, achar(0)), derived_public
end program test_z85
 iret           0
          41 r9nTJ*{UB}y5[KUC$YcL-LkNqDjxD>=)unGz08^0
          41 .%S{T2/*YpGN*GzTFLhTmNfOE&FR0mNFQU4WF?bT
 iret           0
          41 r9nTJ*{UB}y5[KUC$YcL-LkNqDjxD>=)unGz08^0

github.com

Modern Fortran Explained: Incorporating Fortran 2018 (Numerical Mathematics and Scientific Computation)

Modern Fortran Explained: Incorporating Fortran 2018 (Numerical Mathematics and Scientific Computation)

ZeroMQ: Messaging for Many Applications (English Edition)

ZeroMQ: Messaging for Many Applications (English Edition)

ZeroMQ: Using Zeromq and Learn How to Apply Different Message Patterns (In a Nutshell)

ZeroMQ: Using Zeromq and Learn How to Apply Different Message Patterns (In a Nutshell)